开发者

Black and white photo in android [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

how to force a photo into black and white

i want to store Black and white photo when i take photo from mobil开发者_运维百科e camera.


Something like this should work:

public Bitmap greyScaler(Bitmap b) {    
     Bitmap grayscaleBitmap = Bitmap.createBitmap(b.getWidth(),
            b.getHeight(), Bitmap.Config.RGB_565);
     Canvas c = new Canvas(grayscaleBitmap);
     Paint p = new Paint();
     ColorMatrix cm = new ColorMatrix();
     cm.setSaturation(0);
     ColorMatrixColorFilter filter = new ColorMatrixColorFilter(cm);
     p.setColorFilter(filter);
     c.drawBitmap(b, 0, 0, p);
     return grayscaleBitmap;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜