Thank you for visiting the BlackBerry Support Community Forums.
BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)
BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.
"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."
- Kevin Michaluk, Founder, CrackBerry.com
Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.
03-27-2009 08:22 AM
How can we greyscale a colored image? I tried to used LCDUI Graphics , in that we have setGrayScale(int value) method but its not working. Is there any way to achieve this?
Thanks in advance,
Solved! Go to Solution.
04-02-2009 08:56 AM
04-05-2009 11:23 PM - edited 04-05-2009 11:25 PM
Here is an effective but inefficient way to acheive what you're after:
Bitmap b = Bitmap.getBitmapResource( "myImage.png" );
int argb = new argb[ b.getWidth() * b.getHeight() ];
b.getARGB( argb, 0, b.getWidth(), x, y, b.getWidth(), b.getHeight() );
for ( int i = argb.length - 1; i >= 0; --i )
int alpha = argb[i] >> 24;
int red = (argb[i] >> 16) & 0xFF;
int green = (argb[i] >> 8) & 0xFF;
int blue = argb[i] & 0xFF
int grey = ( red + green + blue ) / 3;
int composite = (alpha << 24) | (grey << 16) | (grey << 8) | grey;
argb[i] = composite;
b.setARGB( argb, 0, b.getWidth(), x, y, b.getWidth(), b.getHeight() );
04-06-2009 02:16 AM
It worked just a small typo (int instead of argb while making new object) .
Is it not advisable to use this? Will this have any problem with performance? Actually as far as i have understood. We have to convert the image into raw byte, if we want to do some image editing stuff like providing some effects. If we dont have any other way then this should be fine right?
Please corrects my understanding.
04-06-2009 02:20 AM
This is like adding brightness, contrast and this don't need converting into raw bytes etc.. This will not cause any performance issues..
04-06-2009 01:41 PM - edited 04-06-2009 01:46 PM
There's no real problem with using this method, it's just that it's at the java layer so it has to go through the VM. You can also use a weighted sum. GIMP does it like this: composite = 0.3R + 0.59G + 0.11B.
Obviously the weighted sum method is a bit slower and requires fixed point arithmetic, but it looks better than a simple average.
*edit* Regarding animation, you can do fade to gray by using two bitmaps, one colour one gray scale and fading the grayscale one over top of the colour one. Cheers