前言
在对图片操作时有用过,Matrix.mapRect(),但当时没记录一下,因此今天抽空整(摘)理(抄)一下,方便自己查阅。
正文
Matrix中的接口,有原文注释,大意是对矩形使用矩阵变形,也就是改变矩形中的四个点值。
public boolean mapRect(RectF rect) {
return mapRect(rect, rect);
}
简单代码:
Matrix matrix = new Matrix();
matrix.setScale(3.0f, 3.0f);
RectF srcRectF = new RectF(10, 10, 10, 10);
Log.d(TAG, "srcRectF before : "+ srcRectF.toString());
matrix.mapRect(srcRectF);
Log.d(TAG, "srcRectF after : "+ srcRectF.toString());
输出的结果:
srcRectF before : RectF(10.0, 10.0, 10.0, 10.0)
srcRectF after : RectF(30.0, 30.0, 30.0, 30.0)
参考文章
© 版权声明