【发布时间】:2016-06-11 05:31:40
【问题描述】:
大家好。我是使用矩阵在 android 中进行图像处理的新手。我正在开发一个在设备屏幕上显示位图 #1 的应用程序。
位图 #1 非常大,大约 2592 X 1456,但已按比例缩小以适应设备的屏幕尺寸,仅用于显示目的。
然后我在 Bitmap #1 Canvas 上绘制了嘴唇 Bitmap (#2),使用矩阵(带有旋转、缩放、平移),如上图所示。
正是我想要实现的是保存最终位图的副本,向后缩放到原始大小 (2592 x 1456)。
我尝试通过缩放 Bitmap #1 矩阵来实现它。
这是我迄今为止尝试过的:
// adjust the matrix to the original image size
// new matrix big
Matrix newMatrix = new Matrix();
// copy matrix from small matrix
newMatrix = matrix;
RectF src = new RectF(0,0,backgroundImage.getWidth(), backgroundImage.getHeight());
RectF dst = new RectF(0,0, origBackground.getWidth(), origBackground.getHeight());
newMatrix.setRectToRect(src, dst, Matrix.ScaleToFit.CENTER);
canvas.drawBitmap(bitmap, newMatrix, paint);
我的问题是,在生成的位图 #1 中,嘴唇位图 (#2) 被放置在 x=0 和 y=0 处,而不是在所需的坐标处,缺少指定的旋转。
【问题讨论】:
-
嗨@xAF。这是在画布上绘制的。我没有使用任何自动适应屏幕的小部件。我正在使用矩阵来做到这一点。
-
请查看我建议的编辑(希望我能很好地理解您的问题)
标签: android canvas matrix matrix-multiplication