如何旋转android.graphics.Picture



如何旋转android.graphics.Picture 90度?

*注意:不,它不是位图形式

如果要覆盖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;
}

相关内容

  • 没有找到相关文章

最新更新