How can i get the image matrix co ordinates in android? -
i developing application included crop functionality , in i'm stoped @ below scenario. scenario crop overlay not circulating whole image when apply straightening image if changes crop overlay ratio not working. got code google related matrix, i'm tried using matrix here need find coordinates(edges) of matrix move overlay.
how find it? if have idea please me.. , add image clarity problem
thanks in advance..
using below code didn't exact coordinates of matrix
rectf r = new rectf(); mymatrix.maprect(r); rect rect = new rect((int)r.left,int)r.top,int)r.right+width,int)r.bottom+height);
you should not use maprect
if applying rotation on matrix. advice figure out 4 initial points representing each rectangle edge (the image itself) , use mappoints
instead.
lets have image 200px wide , 200px tall top left corner positioned @ origin (0,0).
if rotate image center (100,100) 45 degrees , scale 200% center have following scenario:
//original image coords float[] points = { 0f, 0f, //left, top 200f, 0f, //right, top 200f, 200f, //right, bottom 0f, 200f//left, bottom }; matrix matrix = new matrix(); //rotate 45 degrees image center matrix.postrotate(45f, 100f, 100f); //scale 200% center matrix.postscale(2f, 2f, 100f, 100f); //get new edges coords matrix.mappoints(points);
after calling matrix.mappoints(points)
points array have updated coords. means points[0], points[1]
have new left top image coord , on.
the indices represents abscissas , odd indices represents ordinates on points
array.
Comments
Post a Comment