2010-09-28 96 views
2

我有一个应用程序的需求,在android中,需要2个图像填充一个在另一个之上。画布中的多个图像旋转

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

我对2张图片重复相同的操作。但结果是,我得到了延迟,这是否可以避免,有没有其他办法。

如果我使用画布,我可以使用多个图像,其中我想只有2个图像被旋转,这有可能吗?

回答

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