画布中的多个图像旋转

时间:2010-09-28 06:41:33

标签: android

我在Android中需要一个应用程序,它需要在另一个上面填充2个图像。

必须根据指南针传感器旋转此图像。 我正在旋转图像,使用矩阵,并创建新的位图,并设置 Imageview上的位图。

我正在重复相同的情况,对于2张图片。但结果是,我得到了延迟,这可以避免,还有其他方法。

如果我使用画布,我可以使用多个图像,其中我想只旋转2个图像,是否可能?

1 个答案:

答案 0 :(得分:3)

我会做的事情如下:

// Two abritary rotations for the bitmaps
int angle1=45;
int angle2=10;

canvas.save();
canvas.rotate(angle1,xcenter,ycenter);
canvas.drawBitmap(...); // However you are drawing you bitmap
canvas.restore();

canvas.save();
canvas.rotate(angle2,xcenter2,ycenter2);
canvas.drawBitmap(...);
canvas.restore();

// where xcenter and ycenter are the location around which you will rotate