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);
}