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
nyte3k
Posts: 8
Registered: ‎11-14-2008
My Device: Not Specified

Bitmap resources loading slow...

Hello,

 

I'm creating a screen almost identical to how the blackberry media screen functions/works (on 4.5), where there are about 4 icons on the top, and one bigger icon in the middle, and when you hover over each icon, the smaller ones glow and the big icon in the middle changes.

 

The problem is that for some reason mine takes about 1 second to change. When you move the trackwheel, the images don't change until about a second. My smaller icons are at most 2kb each, and the bigger image is max 4KB.

 

i'm using setBitmap(Bitmap.getBitmapResource("myImage.png");, so there is nothing speciong going on. I've even tried specifiying the module( setBitmap(Bitmap.getBitmapResource("TheModule", "myImage.png") ), but that didn't help anything.

 

Has anyone else experienced this, and if so how did you fix it?

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Bitmap resources loading slow...

You didn't post code, but make sure you are not calling getBitmapResource() on every paint - this takes forever.  Call this ahead of time and store the bitmaps.

 

 

Please use plain text.
New Developer
nyte3k
Posts: 8
Registered: ‎11-14-2008
My Device: Not Specified

Re: Bitmap resources loading slow...

hmm i'll give that a triy, currently I have the BitmapFields and their onfocus/onunfocus methods calling the getBitmapResource method in the constructor. My code is similar to what's below. Except I have a total of 4 bitmap fields diong the same logic as the one posted below, and one large bitmap field.

 

 

 

.... public MyScreen(){ final Bitmap myImage = Bitmap.getBitmapResource("hover.png"); final Bitmap myImage2 = Bitmap.getBitmapResource("hoverOff.png"); final Bitmap myImage3 = Bitmap.getBitmapResource("bigImage.png");

BitmapField largeBitmapField = new BitmapField(null);

BitmapField bitmapField = new BitmapField(myImage2, BitmapField.FOCUSABLE){ protected void drawFocus(Graphics graphics, boolean on){ on = false; } public void onFocus(int direciton){ setBitmap(myImage); largeBitmapField.setBitmap(myImage3); } public void onUnfocus(){ setBitmap(myImage2); }

 

add(bitmapField);

add(largeBitmapField);

}

 

 

 

Please use plain text.
New Developer
nyte3k
Posts: 8
Registered: ‎11-14-2008
My Device: Not Specified

Re: Bitmap resources loading slow...

I made some code changes, but no luck. I just moved where the bitmap variables were (moved them out of screen constructor)

 

Were you referring to calling this ahead of time and storing the bitmaps on the device itself, and refering to those images later using say... EncodedImage?

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Bitmap resources loading slow...

Re-reading your original post, I would not have approached the issue in quite the same manner. I've done similar things and not had a performance issue.

 

My suggestion is to subclass BitmapField (or write your own), containing both the focus and non-focus icons, and override the paint() and drawFocus() methods in this new class so that the appropiate bitmap is being painted.

 

 

 

Please use plain text.
New Developer
nyte3k
Posts: 8
Registered: ‎11-14-2008
My Device: Not Specified

Re: Bitmap resources loading slow...

i'll give that a try. I'm not really sure if it will improve the performance.

 

I will try it on another device to be sure... maybe it's my device. Of course the simular will work smoothly.

 

any code snippet of what you're describing ?

Please use plain text.
New Developer
nyte3k
Posts: 8
Registered: ‎11-14-2008
My Device: Not Specified

Re: Bitmap resources loading slow...

I ended up removing the background image I was using, and just painted the background with a color, and now it's speedy. I can work with this, but I wonder why BlackBerry's media app works just fine.
Please use plain text.
New Developer
neek2000
Posts: 9
Registered: ‎11-12-2008
My Device: Not Specified

Re: Bitmap resources loading slow...

Implement a BitmapIconField is the best way for this.

 

Remember, Cache all things you always need it, don't read it again & again, it's quite slow. 

Please use plain text.
New Developer
nurikabe
Posts: 44
Registered: ‎08-20-2008
My Device: Not Specified

Re: Bitmap resources loading slow...

Would this slowness apply to any attempt to read from the file system?  For example:

 

try {

Image png = Image.createImage("/" + somePngImage[i]);

} catch (Exception) {

System.out.println(somePngImage[i] + " not found");

}

 

I'm looking for a quick way to test the presensce of images available as resources.

 

Please use plain text.
Developer
safycool
Posts: 198
Registered: ‎04-03-2009
My Device: Not Specified

Re: Bitmap resources loading slow...

I am also having the same problem. The key events are very slow. I am also using background Image. I have no problems with Bold and Pearl, but the application keyevents are very slow on Storm and one more device( i think it is curve) need to check it tomorrow..... I  willl try to remove the background Image and test the speed may be that could improve the performance.

 

I am using Vertical Field Manager to display  the background image by overriding the paint. I have created the bitmap once when the application is started.I am not loading any resource in the paint method.

 

 

 

Thanks...

Please use plain text.