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 in API image scaling function and workaround

I've found this while trying to display thumbnails in an app I am currently developing.

The user takes a snapshot using camera and the app shows a thumbnail of the jpeg file, along with some data. The user also has the option of viewing the image in full screen mode. As camera minimal resolution is 640x480, image scaling is needed for both thumbnail and full screen images. For this task I used a method like this:

 

public static Bitmap getScaledBitmap(EncodedImage jpg, int desiredWidth, int desiredHeight){
<...compute new image scale, named finalScale, for proportional scaling...>

return jpg.scaleImage32(finalScale, finalScale)).getBitmap();
}

The above code was tested and worked fine with most Blackberry devices. But when testing on new models Storm and 8900, we noticed errors when displaying thumbnails. In camera settings screen, if the picture size was set to 2048x1536 the resulting Bitmap was a full black image. Surprisingly, no black Bitmap error occurred when viewing the image in full screen mode, being the same scaling function! Setting picture size to lower values caused the thumbnail to display correctly.

I have found a really stupid workaround for this. Given that the scaling from 2048x1536 to thumbnail size produces errors, and that scaling from 2048x1536 to screen size does not, a two stage scaling is done: 2048x1536 -> screen size -> thumbnail size.

I wonder if anyone else has had trouble with this, or if it is a bug in EncodedImage.scaleImage32 function.

 

 

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

Re: Possible bug in API image scaling function and workaround

What  BlackBerry handheld software version are you testing on?  You can find this under Options, About on the BlackBerry Smartphone.  Can you give some example scales and/or thumbnail resolutions that you are seeing this with?
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
Developer
Posts: 178
Registered: ‎11-19-2008
My Device: Not Specified

Re: Possible bug in API image scaling function and workaround

I posted these details and a snippet to calc the scale on this thread:previous thread

Thumbnails dimensions are 64x48. I don't know the resolution, but camera settings are 2048x1536.

Sorry for the post redundancy.

 

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

Re: Possible bug in API image scaling function and workaround

I have been able to reproduce this and have sent the issue to our development team.  Thanks for reporting this.
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
Developer
Posts: 168
Registered: ‎11-01-2008
My Device: Galaxy S II
My Carrier: Meteor (Ireland)

Re: Possible bug in API image scaling function and workaround

Mark, don't suppose the development team have a workaround other than scaling in two stages?
BlackBerry Development Advisor
Posts: 15,700
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Possible bug in API image scaling function and workaround

Unfortunately no, I don't have a different work around to provide.
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
Highlighted
New Developer
Posts: 5
Registered: ‎09-03-2008
My Device: Not Specified

Re: Possible bug in API image scaling function and workaround

Thank you darkberry,

 

i wanted to use this scaleImage32 method but was getting screwed up with the Fixed32 thing....

New Developer
Posts: 8
Registered: ‎12-03-2009
My Device: Not Specified

Re: Possible bug in API image scaling function and workaround

We had the same issue.

 

When trying to create thumbnails of size 64x64, we got black images.

We thought it was a memory issue and investigated, but apparently this is a bug in the blackberry scaler.

 

To work around it, we simply changed the size to 66x66. Amazingly, it works. (63x63 also seems to work).

 

Also note that on BB Bold (9000) this may cause occasional black strips of pixels to appear in the resulting scaled image. Another scaler bug, maybe?