How to perform a similar operation as AffineTransform.transform on Android?

廉价感情. 提交于 2020-01-03 01:28:10

问题


public Point2D transform(Point2D ptSrc, Point2D ptDst)

Transforms the specified ptSrc and stores the result in ptDst. If ptDst is null, a new Point2D object is allocated and then the result of the transformation is stored in this object. In either case, ptDst, which contains the transformed point, is returned for convenience. If ptSrc and ptDst are the same object, the input point is correctly overwritten with the transformed point.

How do I perform a similar operation on Android? Any pointers will be greatly appreciated. Thanks.


回答1:


You can use the Matrix.mapPoints class for this. For example:

Matrix m = new Matrix(orig);
m.preScale(scale, scale);
m.postTranslate(x, y);

float[] src = { 0.5, 0.3 };
float[] dst = new float[2];
m.mapPoints(dst, src);
//...


来源:https://stackoverflow.com/questions/9019469/how-to-perform-a-similar-operation-as-affinetransform-transform-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!