Hey,
i would like to transform and crop a given image in android. Therefore i have 4 source and 4 destination points to specify the transformation matrix.
i use
float[] src = new float[8];
src[0] = rp[0].getX();
src[1] = rp[0].getY();
src[2] = rp[1].getX();
src[3] = rp[1].getY();
src[4] = rp[2].getX();
src[5] = rp[2].getY();
src[6] = rp[3].getX();
src[7] = rp[3].getY();
int width = image.getWidth();
int height = image.getHeight();
float[] dst = { 0, 0, width, 0, width, height, 0, height };
Matrix trans = new Matrix();
trans.setPolyToPoly(src, 0, dst, 0, 4);
rp contains 4 points specifying 4 corners of a quadrilateral
Then i use
image = Bitmap.createBitmap(image, 0, 0, width, height, trans, false);
to transform the quadrilateral to an rectangle.
After that i would like to crop out the transformed rectangle. But i can not calculate the new position of the corners in the transformed image.
I would be pleased if anybody have a idea or solution for this problem.
greeting
Pascal