01-06-2010 05:52 AM
Can anyone give me the codesnipet for rotete the EncodedImage with 90 degree. I don't want code to rotate the Bitmap because it's give me "OutOfMemory Error" while converting EncodedImage to Bitmap Image.
Other wise , you can provide me the exact code to rotate BitmapField itself.
Thanks In Advance,
01-06-2010 06:04 AM
Here is just example how to operate bitmap argb data.
int argb = new int[original.getWidth() * original.getHeight()];
original.getARGB(argb, 0, original.getWidth(), 0, 0, original.getWidth(), original.getHeight());
Bitmap newBitmap = new Bitmap(original.getHeight(), original.getWidth());
int newArgb = new int[original.getWidth() * original.getHeight()];
for (int i=0; i < original.getHeight(); i++)
for (int j =0; j< original.getWidth();j++)
newArgb[i][j] = argb[j][i];
newBitmap.setArgb(newArgb, 0, original.getHeight(), 0, 0, original.getHeight(), original.getWidth());
01-06-2010 06:15 AM
Unfortunately Eugens approach requires that you create a Bitmap first so will also suffer from OutOfmemory.
However even if you do manage to rotate the image, you can't display it until you create a Bitmap anyway, so I suggest that you just create a scaled Bitmap of the appropriate size, and then rotate it.
Why won't this work for you?
01-06-2010 06:36 AM
@Peter "I suggest that you just create a scaled Bitmap of the appropriate size" - can you please explain about your suggestion in detail, which i was not aware
Thanks in advance
01-06-2010 06:40 AM
@zany - See the API documentation for
I think there are improved methods in OS 5.0 and in fact OS 5.0 may provide a way to rotate an encoded image too.
01-06-2010 06:46 AM
Thank you Peter. I will go through them especially OS 5.0
01-06-2010 07:18 AM
Unless I missed something I don't remeber seeing (I just read through a bunch of classes in the documentation) any way to draw a rotated image using the 5.0 API. You need to do it manually.
01-06-2010 07:56 AM
@rcmaniac25 - I think you are right, just had a quick look myself and couldn't find anything. Loads of new Scale methods though.
Have you seen this?
01-06-2010 08:33 AM
@Peter - sample code which is in the link what you have given will work fine. Only thing for me in that code is about the x, y position what we are passing to drawRotatedBitmap method. We have to calculate them based on the width, height of the image, and angle we are going to rotate the image. If we are going rotate the image in 90, 180, 270 360 degrees, then it will be easy to calculate x, y position. If we are going rotate the image around 145 degree, then it will hard to calculate x, y position.