Theo mặc định điểm xoay là của Canvas (0,0) điểm, và tôi đoán là bạn có thể muốn xoay nó xung quanh trung tâm. tôi đã làm điều đó:
protected void renderImage(Canvas canvas)
{
Rect dest,drawRect ;
drawRect = new Rect(0,0, mImage.getWidth(), mImage.getHeight());
dest = new Rect((int) (canvas.getWidth()/2 - mImage.getWidth() * mImageResize/2), // left
(int) (canvas.getHeight()/ 2 - mImage.getHeight()* mImageResize/2), // top
(int) (canvas.getWidth()/2 + mImage.getWidth() * mImageResize/2), //right
(int) (canvas.getWidth()/2 + mImage.getHeight()* mImageResize/2));// bottom
if(!mRotate) {
canvas.drawBitmap(mImage, drawRect, dest, null);
} else {
canvas.save(Canvas.MATRIX_SAVE_FLAG); //Saving the canvas and later restoring it so only this image will be rotated.
canvas.rotate(90,canvas.getWidth()/2, canvas.getHeight()/ 2);
canvas.drawBitmap(mImage, drawRect, dest, null);
canvas.restore();
}
}
tôi đã trả lời ở đây: http://stackoverflow.com/questions/8608734/android-rotate-bitmap-9 0-degrees-results-in-squashed-image-need-a-true-rotate-b/14475148 # 14475148 – EyalBellisha