如何找到 Android 中图形矩阵的比例
一种可能的解决方案可能是使用矩阵的 mapPoints 函数来映射一个点,并查看它最终在哪里,但除了棘手之外,这对我来说还感觉丑陋和间接。有没有更好的解决方案可以从 Android 图形矩阵中检索比例?
So, it appears to be fairly easy to do pinch zoom in android - but I would also like to be able to snap back the image when it goes out of bounds, and to do that the most reasonable thing seems to be to do things like when the scale < 1, rescale to 1. However, I can't seem to find a good way to retrieve the scale from the the graphics matrix.
One possible solution might be to map a point using the matrix's mapPoints function and see where it ends up, but in addition to being trickly, that just feels ugly and indirect to me. Are there any better solutions for retrieving the scale from an Android graphics matrix?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可能就是您正在寻找的。给出的值如下:
0:缩放 X
1:倾斜 X
2:平移 X 3
:缩放 Y
4:倾斜 Y
5:平移 Y
6:透视 0
7:透视 1
8:透视 2
will probably be what you are looking for. the values given will be as followed:
0 : Scale X
1 : Skew X
2 : Translate X
3 : Scale Y
4 : Skew Y
5 : Translate Y
6 : Perspective 0
7 : Perspective 1
8 : Perspective 2
这是记录矩阵内容的简单方法:
Here's a simple method to log the matrix contents: