我想将整个位图设置为灰度,但我想保留一种颜色,红色或蓝色或绿色或用户喜欢的任何颜色? 这可能是彩色矩阵吗? 这是一个链接,这是我想做但在android中。 How can I convert an RGB image to grayscale but keep one color?
非常感谢。
答案 0 :(得分:1)
试试这个:
ImageView imageView;
Bitmap photo,photo1;
photo1 = Bitmap.createBitmap(photo.getWidth(),photo.getHeight(),photo.getConfig());
for(int i=0;i<photo.getWidth();i++)
{
for(int j=0;j<photo.getHeight();j++){
int p=photo.getPixel(i,j);
int r= Color.red(p);
int g=Color.green(p);
int b=Color.blue(p);
int alpha=Color.alpha(p);
r=0;
g=g+150;
b=0;
alpha=0;
photo1.setPixel(i,j, Color.argb(Color.alpha(p),r,g,b));
}
}
imageView.setImageBitmap(photo1)