Fastest way to rotate big size bitmap

前端 未结 1 1196
迷失自我
迷失自我 2021-01-12 00:01

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 galler

相关标签:
1条回答
  • 2021-01-12 00:55

    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.
    
    0 讨论(0)
提交回复
热议问题