How to resize an image on a BlackBerry
Coming from Android and iPhone I wasn’t expecting the need to do this. I found the documentation a little confusing and there were no quick answers on the web, so here it is.
I find Blackberry application development slightly annoying. I’m not talking about resizing images. RIM please give us an SDK that allows swapping code without a restart, and that will run on a Mac or Linux. It’s based on Java so why doesn’t it have the portability of Java?
public static EncodedImage resizeImage(EncodedImage image, int width, int height)
{
int scaleX = Fixed32.div(Fixed32.toFP(image.getWidth()), Fixed32.toFP(width));
int scaleY = Fixed32.div(Fixed32.toFP(image.getHeight()), Fixed32.toFP(height));
return image.scaleImage32(scaleX, scaleY);
}
30/12/2009 at 4:40 pm Permalink
Hey, It’s Work for me. If you have EncodeImage then Your code will work and if it Bitmap image resize then try below code for the same. Many thanks..
public static Bitmap resizeBitmap(Bitmap image, int width, int height) {
int rgb[] = null , rgb2[] = null;
rgb = new int[image.getWidth() * image.getHeight()];
image.getARGB(rgb, 0, image.getWidth(), 0, 0, image.getWidth(), image
.getHeight());
rgb2 = rescaleArray(rgb, image.getWidth(), image.getHeight(),
width, height);
Bitmap temp2 = new Bitmap(width, height);
temp2.setARGB(rgb2, 0, width, 0, 0, width, height);
return temp2;
}
03/06/2010 at 4:40 am Permalink
Hey, really nice tutorial! It helped me a lot, thank you.
About the SDK, I totally agree. I developed an iPhone App and this is day and night, so complicated to make applications working on every device or most of them (with the Storm to manage, different OS, etc.).