寻找关于post/pre/set Translate的解释(在Matrix对象中)以及如何使用它们。

时间:2022-06-14 21:19:38

The documentation is pretty vague as to what is actually happening when these methods are used. Can someone explain how Matrix actually affects the Bitmap that it's being set to? They use the term concatenate in there, but I'm unclear on how that term applies to coordinate data (having only used it in regard to string manipulation before).

对于使用这些方法时实际发生的情况,文档非常模糊。有人能解释一下矩阵是如何影响位图的吗?它们在这里使用了“连接”这个词,但我不清楚这个词如何应用于坐标数据(之前只在字符串操作中使用过)。

1 个解决方案

#1


128  

The set-methods will replace the current Matrix with new values, disregarding whatever the Matrix contained before. The pre and post method will apply a new transformation before or after whatever the current Matrix contains.

集合方法将用新值替换当前矩阵,而不考虑之前包含的任何矩阵。前置和后置方法将在当前矩阵包含的任何东西之前或之后应用新的转换。

In this example, the rotation will be ignored since we are using the set method and the m will only contain a translation:

在本例中,由于我们使用的是set方法,所以将忽略旋转,而m只包含一个平移:

Matrix m = new Matrix();

矩阵m =新矩阵();

m.setRotate(90);

m.setRotate(90);

m.setTranslate(100, 100);

m。setTranslate(100、100);

In this example, the final matrix will be a translation followed by a rotation:

在本例中,最后的矩阵将是翻译后的旋转:

Matrix m = new Matrix();

矩阵m =新矩阵();

m.setTranslate(100, 100);

m。setTranslate(100、100);

m.postRotate(90);

m.postRotate(90);

In the final example, the final matrix will be a rotation followed by a translation:

在最后的例子中,最后的矩阵将是旋转,然后是翻译:

Matrix m = new Matrix();

矩阵m =新矩阵();

m.setTranslate(100, 100);

m。setTranslate(100、100);

m.preRotate(90);

m.preRotate(90);

There is some more information in this (rather lengthy) post:

在这篇(相当长的)文章中有更多的信息:

http://www.satyakomatineni.com/akc/display?url=displaynoteimpurl&ownerUserId=satya&reportId=2898

http://www.satyakomatineni.com/akc/display?url=displaynoteimpurl&ownerUserId=satya&reportId=2898

Hope it helps.

希望它可以帮助。

#1


128  

The set-methods will replace the current Matrix with new values, disregarding whatever the Matrix contained before. The pre and post method will apply a new transformation before or after whatever the current Matrix contains.

集合方法将用新值替换当前矩阵,而不考虑之前包含的任何矩阵。前置和后置方法将在当前矩阵包含的任何东西之前或之后应用新的转换。

In this example, the rotation will be ignored since we are using the set method and the m will only contain a translation:

在本例中,由于我们使用的是set方法,所以将忽略旋转,而m只包含一个平移:

Matrix m = new Matrix();

矩阵m =新矩阵();

m.setRotate(90);

m.setRotate(90);

m.setTranslate(100, 100);

m。setTranslate(100、100);

In this example, the final matrix will be a translation followed by a rotation:

在本例中,最后的矩阵将是翻译后的旋转:

Matrix m = new Matrix();

矩阵m =新矩阵();

m.setTranslate(100, 100);

m。setTranslate(100、100);

m.postRotate(90);

m.postRotate(90);

In the final example, the final matrix will be a rotation followed by a translation:

在最后的例子中,最后的矩阵将是旋转,然后是翻译:

Matrix m = new Matrix();

矩阵m =新矩阵();

m.setTranslate(100, 100);

m。setTranslate(100、100);

m.preRotate(90);

m.preRotate(90);

There is some more information in this (rather lengthy) post:

在这篇(相当长的)文章中有更多的信息:

http://www.satyakomatineni.com/akc/display?url=displaynoteimpurl&ownerUserId=satya&reportId=2898

http://www.satyakomatineni.com/akc/display?url=displaynoteimpurl&ownerUserId=satya&reportId=2898

Hope it helps.

希望它可以帮助。