更改图片的颜色

//改变图片的颜色
public static Bitmap invert(Bitmap src) {
Bitmap output = Bitmap.createBitmap(src.getWidth(), src.getHeight(),
src.getConfig());
//A表示透明度,R,G,B是RGB调色
int A, R, G, B;
int pixelColor;
int height = src.getHeight();
int width = src.getWidth();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
pixelColor = src.getPixel(x, y);
A = Color.alpha(pixelColor);
R = 255 - Color.red(pixelColor);
G = 255 - Color.green(pixelColor);
B = 255 - Color.blue(pixelColor);
output.setPixel(x, y, Color.argb(A, R, G, B));
}
}
return output;
}

 

posted @ 2016-02-23 16:14  Coding-Null  阅读(238)  评论(0编辑  收藏  举报