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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 39
Registered: ‎03-20-2009
My Device: Not Specified

Resizing bitmap without creating encoded image

Hi,

 

Can any one tell me how to resize a bitmap without creating encoded image from it? When I create encoded image from bitmap and try to resize it, the hour glass displayed all the times. I want to get rid of that. Please advice.

 

Regards,

Roney

Developer
Posts: 241
Registered: ‎11-20-2008
My Device: Not Specified

Re: Resizing bitmap without creating encoded image

I asked the same question in the following thread: 

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=27408#M27408

 

Unfortunately there is no other way to resize a bitmap without creating an encoded image (as of 4.7). In my case, the performance was not so bad. How big is your bitmap? Do you specify the scale parameters correctly (see the thread for an example)?

 

I ran this in Bold. Which device are you using? Is this a bitmap that is part of the project (static image) or it is something that you receive at run time over the network? If you provide more information I can try to give more useful suggestions.

 

 

 

 

 

Developer
Posts: 984
Registered: ‎02-10-2009
My Device: Not Specified

Re: Resizing bitmap without creating encoded image

[ Edited ]

Try this:

 

public static Bitmap resizeBitmap(Bitmap image, int width, int height)
{
int imageWidth = image.getWidth();
int imageHeight = image.getHeight();

// Need an array (for RGB, with the size of original image)
int rgb[] = new int[imageWidth * imageHeight];

// Get the RGB array of image into "rgb"
image.getARGB(rgb, 0, imageWidth, 0, 0, imageWidth, imageHeight);

// Call to our function and obtain rgb2
int rgb2[] = rescaleArray(rgb, imageWidth, imageHeight, width, height);

// Create an image with that RGB array
Bitmap temp2 = new Bitmap(width, height);

temp2.setARGB(rgb2, 0, width, 0, 0, width, height);

return temp2;
}

 

private static int[] rescaleArray(int[] ini, int x, int y, int x2, int y2)
{
int out[] = new int[x2*y2];
for (int yy = 0; yy < y2; yy++)
{
int dy = yy * y / y2;
for (int xx = 0; xx < x2; xx++)
{
int dx = xx * x / x2;
out[(x2 * yy) + xx] = ini[(x * dy) + dx];
}
}
return out;
}  

 

 

Regards

Bikas

  

 

Message Edited by bikas on 06-26-2009 01:08 PM
Developer
Posts: 241
Registered: ‎11-20-2008
My Device: Not Specified

Re: Resizing bitmap without creating encoded image

Well, I should correct myself. When I said there is no other way, I meant there is no other built-in way. If you would like to process an argb array yourself, then you apply any scaling algorithm you want. I haven't benchmarked processing an argb array, because I assumed that looping like this over a large array would be slow. If you apply this technique, I appreciate if you can share how it performs (or may be bikas can do).

 

 

Developer
Posts: 984
Registered: ‎02-10-2009
My Device: Not Specified

Re: Resizing bitmap without creating encoded image

Hi cagdasgerede,

 

Yes its a bit slow than scaling an image using Encoded image.

But i think it will give better scaled image than scale using encoded image.

 

I think sometime you have to sacrifice some performance penalty for quality.


Regards

Bikas

Highlighted
Developer
Posts: 39
Registered: ‎03-20-2009
My Device: Not Specified

Re: Resizing bitmap without creating encoded image

Thanks Bikas & cagdasgerede,

 

But my problem here is the performance and not quality. I am receiving image data over network and I have to resize it (both then way, means up scale and down scale). I am having trouble with encode + resize oprations since it resuluts in a hour glass display and dumping GC messages on console.

 

Regards,

Roney

Developer
Posts: 241
Registered: ‎11-20-2008
My Device: Not Specified

Re: Resizing bitmap without creating encoded image

What is your phone model?

 
How big are your bitmaps? and To what sizes are you scaling up and down?

Developer
Posts: 39
Registered: ‎03-20-2009
My Device: Not Specified

Re: Resizing bitmap without creating encoded image

The phone model is BB Bold 9000. bitmap is of 320 x 480 and trying to resize it something around 616 x 919.
Developer
Posts: 241
Registered: ‎11-20-2008
My Device: Not Specified

Re: Resizing bitmap without creating encoded image

Are you trying to zoom in?

why do you need a bitmap bigger than your screen size?

 

 

Developer
Posts: 39
Registered: ‎03-20-2009
My Device: Not Specified

Re: Resizing bitmap without creating encoded image

It is a project requirement!!!