Android imageview matrix operations
imageview
to display i开发者_如何转开发mage.
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 youYou 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
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
- mapPoints
- mapVectors
- mapRect
Once you have the points (original and the transformed) you can easily calculate the distance using euclidean distance.
精彩评论