首页 > 其他 > 详细

冰冻效果

时间:2014-07-16 19:31:27      阅读:318      评论:0      收藏:0      [点我收藏+]

//冰冻效果
public static Bitmap changeToIce(Bitmap bitmap){
int width = bitmap.getWidth();
int height = bitmap.getHeight();
int dst[] = new int[width*height];
bitmap.getPixels(dst, 0, width, 0, 0, width, height);
Log.i("IceStyle", "width="+width + "; height="+height);
int R, G, B, pixel;
int pos, pixColor;
for(int y=0; y<height; y++){
for(int x=0; x<width; x++){
pos = y*width + x;
pixColor = dst[pos];
R = Color.red(pixColor);
G = Color.green(pixColor);
B = Color.blue(pixColor);

pixel = R-G-B;
pixel = pixel*3/2;
if(pixel < 0)
pixel = -pixel;
if(pixel > 255)
pixel = 255;
R = pixel;

pixel = G - B - R;
pixel = pixel * 3 / 2;
if (pixel < 0)
pixel = -pixel;
if (pixel > 255)
pixel = 255;
G = pixel;

pixel = B - R - G;
pixel = pixel * 3 / 2;
if (pixel < 0)
pixel = -pixel;
if (pixel > 255)
pixel = 255;
B = pixel;

dst[pos] = Color.rgb(R, G, B);
}
}
Bitmap iceBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
iceBitmap.setPixels(dst, 0, width, 0, 0, width, height);
return iceBitmap;
}

冰冻效果,布布扣,bubuko.com

冰冻效果

原文:http://www.cnblogs.com/clarence/p/3837429.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!