Welcome!

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

Reply
New Developer
Posts: 3
Registered: ‎02-11-2010
My Device: Blackberry Storm
My Carrier: Verizon
Accepted Solution

setARGB causes Bitmap to be drawn slower

It seems calling setARGB on a Bitmap causes it be drawn 25x slower. The effects of setARGB are permanent, once it's called the Bitmap is forever drawn at a slower rate. I've noticed calling setARGB on a Bitmap in a constructor doesn't cause the slow down, only in other functions. Is there anyway to change this, anyway to keep the Bitmap drawn at an accelerated rate? Or is there another way to do the same function as setARGB?

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: setARGB causes Bitmap to be drawn slower

Welcome to the forums.  Smiley Happy

 

This is a bit worrying. Smiley Surprised

 

Should I be able to see this for myself, if I just do a get and then a set, even if they are the same thing?

 

What size image are you testing with and is this on the device or the simulator?

New Developer
Posts: 3
Registered: ‎02-11-2010
My Device: Blackberry Storm
My Carrier: Verizon

Re: setARGB causes Bitmap to be drawn slower

I tested this on the simulator with System.getCurrentTimeMillis() over 1000 iterations to get an average for each case. Without setARGB, the image draws at about 0.08 ms (on average). Once I do setARGB, this jumps up to around 2 ms. Still very tiny on the simulator, but on the device these numbers are probably 20x worse.

 

The size of the image is 480x360. Doing a get and then set should work.

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

Re: setARGB causes Bitmap to be drawn slower

I would caution you from making to many broad assumptions based on simulator timing.  But i agree that this seems disconcerting.  I would guess that calling setARGB activates an alpha level on the bitmap, which will cause it to be drawn slower because of alpha blending that needs to happen.  But that is just a Wild **bleep** Guess

Developer
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: setARGB causes Bitmap to be drawn slower

Are you making these calls on the event thread? Is the call from the constructor off the event thread? How many times are you calling setARGB?

New Developer
Posts: 3
Registered: ‎02-11-2010
My Device: Blackberry Storm
My Carrier: Verizon

Re: setARGB causes Bitmap to be drawn slower

haagmm is a winner!

 

I re-ran the test, realizing the setARGB I was doing was adding some alpha to it. Seems to have fixed it!