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

Posts: 23
Registered: ‎08-02-2008
My Device: BlackBerry Dev Alpha
My Carrier: Bharti Airtel

Re: How to crop image in Blackberry ?

Hi Peter


Could you please post sample of how you did the rotation with method one ? Did you use the (r, theta) formula for rotation ?


Is there anyone who did the bresenham's algorithm for the fastest image rotation logic in BB, if so then please give us the idea of how to do it ?



Posts: 410
Registered: ‎06-03-2010
My Device: Z10 Red
My Carrier: Free

Re: How to crop image in Blackberry ?

Just had the same problem.


If any of you still wonder how to crop an image easily, please enjoy:





public static Bitmap cropBitmap(Bitmap original, int width, int height) {
    Bitmap bmp = new Bitmap(width, height);
     int x = (original.getWidth() / 2) - (width / 2); // Center the new size by width
    int y = (original.getHeight() / 2) - (height / 2); // Center the new size by height
    int[] argb = new int[width * height]; 
    original.getARGB(argb, 0, width, x, y, width, height);
    bmp.setARGB(argb, 0, width, 0, 0, width, height);
    return bmp;



New Developer
Posts: 137
Registered: ‎02-04-2010
My Device: Tour 9630
My Carrier: verizon

Re: How to crop image in Blackberry ?

great code. thanks.

is there way to set the shading of an image? for example to 50%.