[android-developers] Re: Grayscaling

2009-05-28 Thread Gavin Aiken
Hi Marco, Would you mind giving a brief code snippet of how this might work? I've been trying to get a similar function to run faster but when I use the bitmap the values I thought were written by the canvas aren't there. Kind regards, Gav On Tue, Apr 21, 2009 at 12:21 AM, Marco Nelissen

[android-developers] Re: Grayscaling

2009-05-28 Thread Streets Of Boston
- Create a mutable bitmap from immutable. But instead of a copy, just create an empty one with the same width and height as the original one. - Create a canvas from this mutable bitmap (new Canvas(mutable)); - Create a ColorFilter object. Set its saturation to 0 (this is one way of doing this).

[android-developers] Re: Grayscaling

2009-05-28 Thread Gavin Aiken
Thanks for the fast response. I can't seem to saw the changes made by the canvas in the original bitmap, my code is as follows; int old = input.getPixel(0, 0); Canvas c = new Canvas(input); c.drawARGB(a, r, g, b); int n = input.getPixel(0, 0); if(old==n)

[android-developers] Re: Grayscaling

2009-05-28 Thread Streets Of Boston
Are you sure your canvas' clip-rect is not empty? Most calls to Canvas.clip() *intersect* with the old clip- rect... not replace the old clip-rect. Call Canvas.getClipBounds() to make sure. On May 28, 2:44 pm, Gavin Aiken gavin.ai...@imperial.ac.uk wrote: Thanks for the fast response. I

[android-developers] Re: Grayscaling

2009-04-20 Thread sm12
The problem is my Bitmap was immutable. I made it mutable. I also used pixels array. Initially by bitmap is taken from source. Then Im setting it to mutable as follows: mutable = immutable.copy(Config.RGB_565, true); But now, my image is coming blue-scaled. Why?

[android-developers] Re: Grayscaling

2009-04-20 Thread sm12
Solved. The problem was in the parameters of Color.rgb. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To

[android-developers] Re: Grayscaling

2009-04-20 Thread clark
for(int y = 0; y imgH; y++) for(int x = 0; x imgW; x++)         {                 int color = bitmap.getPixel(x, y);                 int r = (color 16) 0xff;                 int g = (color 8) 0xff;                 int b = color 0xff;                 color = Color.rgb(r/3, g/3,

[android-developers] Re: Grayscaling

2009-04-20 Thread Marco Nelissen
You can do this more efficiently by using a Paint and a ColorFilter. On Mon, Apr 20, 2009 at 3:59 PM, sm12 mata...@gmail.com wrote: Solved. The problem was in the parameters of Color.rgb. --~--~-~--~~~---~--~~ You received this message because you are