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
Developer
Posts: 178
Registered: ‎11-19-2008
My Device: Not Specified

possible bug on EncodedImage.scaleImage32 (yes, again)

Here's a strange behavior I found while downscaling images with EncodedImage.scaleImage32 method. When performed on JPEG images, all works fine, however this is not the case with GIF images.

I am using GIF images with transparent background, about 100x100 px, and scaling them to 64x64. The non transparent parts are scaled correctly, but the resulting image is the same size as the original (100x100), keeping a huge transparent padding at right and bottom. It is something like this:

 

 

----------------------
| | |
| | |
|----------- |
| |
| |
|--------------------|

| |
w1 w2

w1: expected image size. The non transparent parts of the image are correctly included here.

w2: original image size, and also scaled image size.

Areas between w2 and w1 are fully transparent background

 I think it only happens on certain simulators. The workaround is cropping the resulting image to it's expected width (w1).

 

I was using Eclipse 3.4 with BB plugin alpha, component pack 4.5 and simulator 8300-4.2.2.146

 

Developer
Posts: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.3.2.858, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: possible bug on EncodedImage.scaleImage32 (yes, again)

What functions are you calling to get the width/height?

 

If you are using getHeight/getWidth than you should call getScaledHeight/getScaledWidth. If you scaled it and then draw it and you see this "buffer" then it is a bug. If you are just looking at the width and height then it might not be a bug.

 

The only reasoning that my resoning would be wrong is that you said it only happens on certain simulators.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
Posts: 178
Registered: ‎11-19-2008
My Device: Not Specified

Re: possible bug on EncodedImage.scaleImage32 (yes, again)

Yes, I can see the image, both before and after taking my medication  XD

Highlighted
Developer
Posts: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.3.2.858, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: possible bug on EncodedImage.scaleImage32 (yes, again)

Ha ha, Ok have you only tried it with GIF and JPEG or did you try it on other image types? I know JPEG and WBMP are the only ones that don't support alpha but I don't know if it's the EncodedImage subtype (GIFEncodedImage) or if it is a non-mutable function and it simply changes the scale values on the EncodedImage. I have a feeling that I am just babbling but I use this in a couple areas and want to make sure that I don't encounter any errors.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.