tags:

views:

38

answers:

1

I've seen this code on the web:

Bitmap grayscaleBitmap = Bitmap.createBitmap(width, height, 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(bmp, 0, 0, p); 

My questions are: 1. Is 'bmp' supposed to be the color bitmap I want to affect? 2. How do I get the 0-255 value of the grayscale?

Thanks.

+2  A: 
  1. That depends on how bmp is defined (but it looks like that is a correct assumption)
  2. gray = (0.299*r + 0.587*g + 0.114*b); (from here)
Michael Todd
Thanks.........