Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Posts: 62
Registered: ‎07-29-2008
My Device: Not Specified

Bitmap editing

Trying to change the color of a BlackBerry Bitmap. I can get this to work for MIDP Image type

but will start to use EncodedImage. So whats wrong with this?

basically get the ARGB and set my color. The color does not change for the new image

 I assume getBitmap makes a copy. I see noway to create a EncodedImage from a Bitmap?

So a little help here.


  static private EncodedImage colorImage(EncodedImage image, int color){
        int[] rgbData= new int[image.getWidth()*image.getHeight()];
        Bitmap bm= image.getBitmap();


        for (int i=0; i<rgbData.length; i++)
            rgbData[i]= (rgbData[i]&0xFF000000)| color;
        bm.setARGB(rgbData,0, image.getWidth(),0,0,image.getWidth(),image.getHeight());
        return image;

BlackBerry Development Advisor
Posts: 15,693
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Bitmap editing

The Bitmap bm you are modifying is a stand alone copy of the image.  Changing it does not affect EncodedImage image.


Returning bm should provide you with your modified image.  There are no APIs in the BlackBerry API set that allow you to convert a Bitmap to an Encoded image, however a solution to this has been posted in this thread:



Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker