Skip to content Skip to sidebar Skip to footer

Fastest Way To Rotate Big Size Bitmap

I am working with large size images and when I try to rotate them (applying matrix on the bitmap) a lot of seconds occurs. I've seen that android system gallery can accomplish this

Solution 1:

When doing modifications to a large image, create a low quality bitmap copy of it and use it for showing instant rotation or other editing effects. Once user is stopped motion (or left slider control) replace the low quality bitmap with the original image with same effects applied to it. This will significantly improve user experience. Try and let me know.

This might sound like a deviation from the original requirement- you can draw a rectangle instead of rotating the whole image in real time. In the end, what user needs is an indication of how much his image has rotated. This will be faster and can easily be done on UI thread without lag.

This is the simplest rotation on canvas code

canvas.save(); //save the position of the canvas
canvas.rotate(angle, X + (imageW / 2), Y + (imageH / 2)); //rotate the canvas
canvas.drawBitmap(imageBmp, X, Y, null); //draw the image on the rotated canvas
canvas.restore();  // restore the canvas position.

Post a Comment for "Fastest Way To Rotate Big Size Bitmap"