Labeeb Panampullan
Labeeb Panampullan

Reputation: 34823

Android imageview matrix operations


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

Upvotes: 0

Views: 4157

Answers (2)

numan salati
numan salati

Reputation: 19494

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.

Upvotes: 0

Vlad
Vlad

Reputation: 1680

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

Upvotes: 1

Related Questions