2013-12-20 61 views
0

我有从顶角拍摄的赛道图像。我想将这张图放大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()); 

它给了我在后台放大,但我不知道如何在图像中移动此变焦。

有谁知道如何做到这一点?

谢谢!

回答

0

我设法解决它通过缩放画布本身之前绘制背景!

canvas.scale(x,y); 
canvas.drawBitmap();