【发布时间】:2015-03-25 23:57:55
【问题描述】:
我想知道如何通过单击按钮来更改图库中图像的颜色。我有多项活动需要完成。我已经通过使用意图将图像从画廊传递到其他活动。我现在需要做的是通过单击按钮将该图像从画廊转换为灰度..你能给出一些想法吗?
还有一个,android中可以使用什么图像处理库?谢谢。
【问题讨论】:
标签: android eclipse image colors imagelibrary
我想知道如何通过单击按钮来更改图库中图像的颜色。我有多项活动需要完成。我已经通过使用意图将图像从画廊传递到其他活动。我现在需要做的是通过单击按钮将该图像从画廊转换为灰度..你能给出一些想法吗?
还有一个,android中可以使用什么图像处理库?谢谢。
【问题讨论】:
标签: android eclipse image colors imagelibrary
已经在这里回答了:Android : Converting imageview to bitmap, to grayscale, bitmap to imageview
public Bitmap toGrayscale(Bitmap bmpOriginal){
int width, height;
height = bmpOriginal.getHeight();
width = bmpOriginal.getWidth();
Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
Canvas c = new Canvas(bmpGrayscale);
Paint paint = new Paint();
ColorMatrix cm = new ColorMatrix();
cm.setSaturation(0);
ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
paint.setColorFilter(f);
c.drawBitmap(bmpOriginal, 0, 0, paint);
return bmpGrayscale;
}
【讨论】: