0

android.graphics.Pictureを90度回転させる方法は?

*注:ビットマップ形式ではありません

4

1 に答える 1

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;
}
于 2013-01-08T22:09:34.513 に答える