【发布时间】:2010-09-25 01:21:11
【问题描述】:
我正在尝试旋转位图(比 Canvas 大),使其与 Canvas 居中并及时重复,以使其看起来像旋转。我想发布一张图片来解释这种情况,但我不能(没有足够的声誉;这很可惜,因为我花了很多时间来做这件事:()。无论如何,我希望你能理解问题所在。
由于我不希望绘制到 Canvas 的其余可绘制对象也被旋转,因此我不能使用 Canvas.rotate()。所以我尝试了使用矩阵的所有不同组合,并使用偏移量将位图绘制到画布上,例如:
Matrix matrix = new Matrix();
matrix.postRotate(degree); //degree is increasing with time
mrotatedbackground = CreateBitmap(mbackground, (mbackground.getWidth()-screenwidth)/2, (mbackground.screenHeight()-screenheight)/2, screenwidth, screenheight, matrix, true);
canvas.drawBitmap(mrotatedbackground, -screenwidth/2, -screenheight/2, paint);
【问题讨论】:
-
你有没有遇到过类似的挑战?
标签: android canvas bitmap rotation