【发布时间】:2026-01-10 01:15:01
【问题描述】:
我正在使用矩阵在画布上旋转位图,如下所示:
public void drawRotatedPixmap(Bitmap bitmap, int x, int y, int srcX, int srcY, int srcWidth, int srcHeight, int degrees)
{
srcRect.left = srcX;
srcRect.top = srcY;
srcRect.right = srcX + srcWidth;
srcRect.bottom = srcY + srcHeight;
dstRect.left = x;
dstRect.top = y;
dstRect.right = x + srcWidth;
dstRect.bottom = y + srcHeight;
matrix.reset();
matrix.setRotate(degrees, x+srcWidth/2, y+srcHeight/2);
canvas.setMatrix(matrix);
canvas.drawBitmap(bitmap, srcRect, dstRect, null);
canvas.setMatrix(null);
}
原始位图图像非常像素化并且旋转它我得到这个:
通过这种方式,图像重新缩放并且边缘非常明显。 我会得到的结果如下:
可以通过在画布上绘图来做到这一点,还是应该使用 openGL?
注意:精灵图片仅供测试,取自谷歌
【问题讨论】:
标签: java android canvas bitmap rotation