矩阵缩放后更改RectF值

时间:2018-08-25 08:11:52

标签: android matrix canvas

当我画一条线时,我的RectF和Matrix值是

enter image description here

Matrix{[1.0, 0.0, 254.76411][0.0, 1.0, 388.6726][0.0, 0.0, 1.0]}
RectF(0.0, 0.0, 297.0, 379.0)

当我像下面的图片一样重新缩放时,值是

enter image description here

Matrix{[3.0136142, 0.0, 48.238903][0.0, 3.0136142, 177.33151][0.0, 0.0, 1.0]}
RectF(0.0, 0.0, 297.0, 379.0)

在这里,我想基于Matrix更改RectF的右值和下值,因此它看起来像跟随,而不是缩放/模糊。

enter image description here

我知道它的可能,但是我不知道该怎么做,所以我需要一些帮助。

1 个答案:

答案 0 :(得分:0)

您可以使用mapRect中的Matrix方法来获取当前的RectF值,如下所示。

RectF rectF2 = new RectF();
matrix.mapRect(rectF2, rectF);

这里rectF2是当前的RectF。