How to resize an image on a BlackBerry

Ray » 05 August 2009 » In BlackBerry »

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

Related Links

Tags: ,

Trackback URL

2 Comments on "How to resize an image on a BlackBerry"

  1. admin
    Shani Shah
    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;
    }

  2. admin
    Damien Poulain
    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.).

Hi Stranger, leave a comment:

ALLOWED XHTML TAGS:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam Protection by WP-SpamFree

Subscribe to Comments