如何反转绘制到画布中的图像?在画布上反转绘制位图
我有以下几点:
canvas.save();
canvas.drawBitmap(image.current(), null, currentBounds(), Paints.BLANK);
canvas.restore();
我怎样才能让现在的影像drawed fliped X轴进currentBounds()?
我已经找到了一些答案,表明Matrix的用法,但我不知道是否有更简单的方法?这样的油漆打开了一些标志。
编辑:
以下是我尝试用矩阵变换:
Rect currentBounds = currentBounds();
currentBounds.offset((int)offset.x(), (int)offset.y());
float scale = image.current().getWidth()/currentBounds.width();
Matrix matrix = new Matrix();
matrix.setScale(- scale - 1, scale + 1);
matrix.postTranslate(currentBounds.left, currentBounds.top);
canvas.drawBitmap(image.current(), matrix, Paints.BLANK);
canvas.drawRect(currentBounds, Paints.STROKE_BLUE);
以下是这场平局的结果:
https://dl.dropbox.com/u/28683814/game.png
可以看出,精灵被从0,0拖到左边,并没有完全完成currentBounds(),我做错了什么?
我认为[这](HTTP:/ /stackoverflow.com/a/7775153/314784)是最好的方法。它使用矩阵,但并不那么难。 – 2012-08-07 19:33:28
使用矩阵应该是直截了当的。 – Doomsknight 2012-08-07 19:34:07
可能是最好的方法,请阅读我编辑的答案,看看新的错误 – 2012-08-07 23:27:54