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: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-, Z10 (STL100-3)-, Z30 (STA100-5)-, Passport (SQW100-1)-, PlayBook (16GB)-
My Carrier: Verizon

Re: Rotate EncodedImage Object or BitmapField Object.

@Peter: Thats pretty cool, I wonder if it works "perfectly" or if it has some glitches. I also wonder how fast it would go. Something to try later.


I actually gave some thought to this and I thought of using a drawPath function but couldn't figure out how and then I remembered SVG. It would have a large amount of overhead but would probably have perfect rotation. Create a SVG document, create a temp. image and put the image path into the basic SVG image. Take the image and change the transformation matrix (they have a simple rotate function for SVGMatrix) and you can draw a rotated image. A lot of overhead put a possible solution if that other one doesn't work.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Rotate EncodedImage Object or BitmapField Object.

@zany  & @rcmaniac25 - the link I provided was just for information, it was not a suggestion, I have never tested it.   I think if it works it is likely to be pretty fast.  Not sure about glitches.  That transformation does my head in. 


There are other posts on this forum where more traditional (i.e. pixel at a time) rotation is discussed.  If I remember correctly I have contributed some sample code to at least one of these, because I had a requirement to do some rotation for a project. 


I suspect SVG is good way to go, but I have no experience with it.


Having said all that, I hope the original poster has managed to scale the image into something that can be rotated.  90 degrees rotation is easy.  There is definitely simple sample code to do that somewhere on the forum (again I seem to remember that I contributed to one of the Threads)

New Developer
Posts: 17
Registered: ‎10-28-2008
My Device: Not Specified

Re: Rotate EncodedImage Object or BitmapField Object.

I needed something simple to do a 90 degree rotation and trimmed down what was already posted to the following which some may find useful.


    public static Bitmap rotateBitmap(Bitmap a_bitmap)
        int width  = a_bitmap.getWidth();
        int height = a_bitmap.getHeight();
         int row[]  = new int[width];
        Bitmap bitmap90 = new Bitmap(height, width);
        for (int i = 0; i < height; ++i)
            a_bitmap.getARGB(row, 0, width, 0, i, width, 1);
            bitmap90.setARGB(row, 0, 1, (height - i - 1), 0, 1, width);
        return bitmap90;