Kevin Prichard wrote:chonada wrote:I am doing a photoeditor application and we have a button to rotate the image in the canvas (which is actually an image switcher), now while i did the rotation using the Matrix, i found that the image is shrinking when rotating (noticeable when rotating continuously), code snippet given below, any suggestions will be appreciated.
Thanx in advance.
Assuming you are running the above code for each step of a rotation, you are first grabbing bmp from mSwitcher, then rotating it, then putting it back into mSwitcher, right? Once the bmp is rotated into flippedBmp, its dimensions are changed, and are greater. But I think that the classes used will fit the rotated image within the target drawing area, which means shrinking.
Think of the diagonal distances, from corner to corner: if you rotate bmp 45 deg, the width and height of flippedBmp are now greater than the original bmp.
You need to have a bmp that is at least as large as the maximum line distance found in the original bmp, in each dimension. Remember the Pythagorean theorem. With the original image spec of w * h, the image resulting from the rotation will need to be sqrt(w^2 + h^2) in both dimensions, to prevent shrinkage, to give it the maximum room needed to arbitrarily rotate without shrinking.
This is just a wild guess, haven't run your code, but I have encountered this in the past.
I'm also trying to do this but with the same problem. The think is that if it doesn't shrink, it doesn't get aligned with a textview that i have before the imageview.
Anyone found an answer to this problem? The hypot doesn't help 'cause it FC with "java.lang.IllegalArgumentException: x + width must be <= bitmap.width()"