【问题标题】:Scrolling, zoomed in, background滚动、放大、背景
【发布时间】: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


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-24
      • 2010-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多