Android imageview矩阵运算
我使用 imageview
来显示图像。
我将比例类型设置为 ScaleType.MATRIX
有缩放
(缩放
)、拖动
等选项。所有这些都是通过矩阵操作来完成的,主要是 postTranslate
和 postScale
我现在的问题是可以拖动它以使图像不在屏幕中
那么我们如何获得它被拖动的程度。
简述
我有两个矩阵(android.graphics.Matrix
),一个是初始阶段,另一个是拖动和缩放后得到的。现在我想从这两个矩阵计算它在x方向和y方向移动了多少?
我需要在这里执行什么矩阵运算。
谢谢
Me used imageview
to display image.
I set the scale type as ScaleType.MATRIX
There is option for scaling
(zooming
), dragging
and all. All this are done by doing matrix manipulations mainly postTranslate
and postScale
My problem now it can be drag such that the image is not in the screen
So how we get how much it is dragged.
In brief
I have two matrix (android.graphics.Matrix
) one the initial stage and the other that i got after drag and zoom. Now from this 2 matrices i want to calculate how much it moved in x-direction and y-direction?
What matrix operation i need to do here.
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 getValues 函数获取矩阵值的浮点数组。矩阵的第二个 (Matrix.MTRANS_X) 和第五个 (Matrix.MTRANS_Y) 值是 x 和 y 方向上的转换。
http://developer.android.com/reference/android/graphics/Matrix.html
You can get float array of matrix's values using getValues function. The 2nd (Matrix.MTRANS_X) and 5th (Matrix.MTRANS_Y) values of matrix are transitions in x and y directions.
http://developer.android.com/reference/android/graphics/Matrix.html
您需要应用矩阵来获取转换后的坐标。 Matrix 类有一些方法可以为您提供转换后的坐标。
查看
一旦你有了点(原始点和转换后的点),你就可以使用欧几里得距离轻松计算距离。
You need to apply the matrix to get the transformed coordiantes. Matrix class has a few methods that will give you tranformed coordinates.
Look at
Once you have the points (original and the transformed) you can easily calculate the distance using euclidean distance.