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
naveensh
Posts: 51
Registered: ‎09-18-2008
My Device: Not Specified

Re: Resizing a Bitmap using .scaleImage32 instead of .setScale

Hi,

 

i am getting variable Fixed32 error;

if i declare it has int; it says int  cannot be dereferenced.

 

please help is ther any api i need to import for this.

 

thanks in advance.

Please use plain text.
Contributor
bhuvana16
Posts: 12
Registered: ‎09-16-2010
My Device: 9000
My Carrier: t-mobile

Re: Resizing a Bitmap using .scaleImage32 instead of .setScale

Hi ,

  I have an image with 2.19 MB on my blackberry gallery. When I open it using native, it srinks the image perfectly to the screen and shows

 

I need to do the same when the user clicks on my image inside my application. when i used the code provided by Bikas, it fits to screen but cant see the entire image.. may be first half streched.

 

can anyone help me how to fit the bigger size image to the screen? Basically shrink it with gud display to the screen?

 

Thanks

Bhuvana

Please use plain text.
Contributor
jaywhy13
Posts: 31
Registered: ‎11-14-2012
My Device: Blackberry 9780
My Carrier: Digicel

Re: Resizing a Bitmap using .scaleImage32 instead of .setScale

I'm having some trouble getting this working... I just want to scale my image down by half. When I check getWidth and getHeight after doing scaleImage32 the image is the same dimensions. Am I doing something wrong here. I tried calling it with 

scaleImage(data, 0.5); 

 

public static byte[] scaleImage(byte[] data, double scale) {
EncodedImage image = EncodedImage.createEncodedImage(data, 0, data.length);

int currentWidth32 = Fixed32.toFP(image.getWidth());
int currentHeight32 = Fixed32.toFP(image.getHeight());

int requiredWidth = (int) (image.getWidth() * scale);
int requiredHeight = (int) (image.getHeight() * scale);

int requiredWidth32 = Fixed32.toFP(requiredWidth);
int requiredHeight32 = Fixed32.toFP(requiredHeight);

int scaleXFixed32 = Fixed32.div(currentWidth32, requiredWidth32);
int scaleYFixed32 = Fixed32.div(currentHeight32, requiredHeight32);

EncodedImage scaledImage = image.scaleImage32(scaleXFixed32, scaleYFixed32);
Utils.log("Image now has size: " + scaledImage.getWidth() + "x" + scaledImage.getHeight());
return scaledImage.getData();
}

Please use plain text.
Contributor
jaywhy13
Posts: 31
Registered: ‎11-14-2012
My Device: Blackberry 9780
My Carrier: Digicel

Re: Resizing a Bitmap using .scaleImage32 instead of .setScale

Does the code here actually shrink the file size? I should perhaps ask that. 

Please use plain text.
Developer
peter_strange
Posts: 19,603
Registered: ‎07-14-2008
My Device: Not Specified

Re: Resizing a Bitmap using .scaleImage32 instead of .setScale

[ Edited ]
Please use plain text.