码迷,mamicode.com
首页 > 其他好文 > 详细

卡通效果

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

标签:color   os   width   art   for   re   

// 卡通效果
public static Bitmap changeToCarton(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);

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); // (color >> 16) & 0xFF
G = Color.green(pixColor); // (color >> 8) & 0xFF;
B = Color.blue(pixColor); // color & 0xFF
pixel = G - B + G + R;
if (pixel < 0)
pixel = -pixel;
pixel = pixel * R / 256;
if (pixel > 255)
pixel = 255;
R = pixel;

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

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

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

卡通效果,布布扣,bubuko.com

卡通效果

标签:color   os   width   art   for   re   

原文地址:http://www.cnblogs.com/clarence/p/3837413.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!