2012-12-12 30 views

回答

1

如果您正在覆蓋onDraw()那麼你就可以做到以下幾點:

canvas.save(); 
canvas.rotate(90f, picture.getWidth()/2, picture.getHeight/2); 
canvas.drawPicture(picture); 
canvas.restore(); 

如果您只想旋轉圖像本身,那麼你可以使用此方法:喜歡這個?]

public Picture rotatePicture(float degrees, Picture picture) { 
    int width = picture.getWidth(); 
    int height = picture.getHeight(); 

    Picture rotatedPicture = new Picture(); 
    Canvas canvas = rotatedPicture.beginRecording(width, height); 
    canvas.save(); 
    canvas.rotate(degrees, width/2, height/2); 
    picture.draw(canvas); 
    canvas.restore(); 
    rotatedPicture.endRecording(); 

    return rotatedPicture; 
} 
+0

我實際上這樣做,但這取決於你想要完成的。 c.drawPicture(picture,r); \t \t c.save(); \t c.rotate(90f,picture.getWidth()/ 2,picture.getHeight()/ 2); \t c.restore(); – MobileMon