【发布时间】:2013-12-20 09:19:03
【问题描述】:
我有一张从顶部角度拍摄的赛道图像。我想把这张图片放大大约 2 倍。 一辆汽车将在背景上移动,背景由于它被放大,应该在汽车移动时全景并跟随汽车。
我设法放大了一张背景图片,但让它跟随汽车有点麻烦。
这是我目前得到的:
float height = (float) background.getHeight();
float width = (float) background.getWidth();
float newLeft = 0
float newTop = 0;
float newWidth = background.getWidth() * 2; //zoom in effect
float newHeight = background.getHeight() * 2; //zoom in effect
Matrix mat = new Matrix();
mat.postTranslate(newLeft, newTop);
mat.setScale(newWidth / width, newHeight / height);
canvas.drawBitmap(background, mat, new Paint());
它给了我一个放大的背景,但我不知道如何在图像上移动这个缩放。
有人知道怎么做吗?
谢谢!
【问题讨论】:
标签: java android matrix android-canvas