发布于 2017-10-14 22:38:00 | 149 次阅读 | 评论: 0 | 来源: 网友投递
Android移动端操作系统
Android是一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由Google公司和开放手机联盟领导及开发。尚未有统一中文名称,中国大陆地区较多人使用“安卓”或“安致”。
霓虹是用来描绘图像的轮廓,勾画出颜色变化的边缘,加强其过度效果,使图像产生轮廓发光的效果。
主要步骤为
1、根据当前像素与其右方和下方像素的梯度运算;
2、然后将结果值作为当前像素值,即将原图当前下像素的RGB分量与其右方和下方像素做梯度 运算(差的平方和平方根);
3、然后将梯度值作为处理后的像素的RGB三个分量;
用代码实现如下:
//霓虹
public static Bitmap Neon(Bitmap bitmap){
int w = bitmap.getWidth();
int h = bitmap.getHeight();
Bitmap resultBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565);
int color = 0;
int r,g,b,r1,g1,b1,r2,g2,b2;
int[] oldPx = new int[w * h];
int[] newPx = new int[w * h];
bitmap.getPixels(oldPx, 0, w, 0, 0, w, h);
for(int y = 0; y < h - 1; y++){
for(int x = 0; x < w - 1; x++){
color = oldPx[x+y*w];
r = (color >> 16) & 0xFF;
g = (color >> 8) & 0xFF;
b = (color >> 0) & 0xFF;
int newcolor = oldPx[x+1+y*w];
r1 = (newcolor >> 16) & 0xFF;
g1 = (newcolor >> 8) & 0xFF;
b1 = (newcolor >> 0) & 0xFF;
int newcolor2 = oldPx[x+(y+1)*w];
r2 = (newcolor2 >> 16) & 0xFF;
g2 = (newcolor2 >> 8) & 0xFF;
b2 = (newcolor2 >> 0) & 0xFF;
int tr = (int) (2*Math.sqrt(((r-r1)*(r-r1)+(r-r2)*(r-r2))));
int tg = (int) (2*Math.sqrt(((g-g1)*(g-g1)+(g-g2)*(g-g2))));
int tb = (int) (2*Math.sqrt(((b-b1)*(b-b1)+(b-b2)*(b-b2))));
newPx[x+y*w] = (255 << 24)|(tr << 16)|(tg << 8)|(tb);
}
}
resultBitmap.setPixels(newPx, 0, w, 0, 0, w, h);
return resultBitmap;
}
对应的效果图如下:
原图如下:
挺具有魔幻色彩的。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持PHPERZ。