【问题标题】:Get measured size and position of bitmap on canvas after 2D transformation在 2D 转换后获取画布上位图的测量大小和位置
【发布时间】:2011-08-20 23:38:24
【问题描述】:

我在 Canvas 上绘制了一堆位图,并应用了 2D 转换(android.graphics.Camera 和 android.graphics.Matrix)。如何获取 Canvas 上位图的大小/位置?大小将是在画布上呈现的位图的边界,位置将是边界的上/左角的坐标。所有位图都是没有 Alpha 通道的常规矩形。

【问题讨论】:

    标签: android canvas bitmap


    【解决方案1】:

    矩阵类有一个mapRect函数用于此目的:

    mapRect(RectF dst, RectF src) Apply this matrix to the src rectangle, and write the transformed rectangle into dst.

    将图像的尺寸作为源(如果您使用整个图像,则为 x,y 为 0,0),它会将转换后的尺寸返回为 dst 矩形。

    【讨论】:

      猜你喜欢
      • 2011-07-30
      • 1970-01-01
      • 2012-02-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多