There are many ways to do image mirroring in Android, today is learning!
two ways are as follows:
Copy Code code as follows:
Method One
Matrix matrix = new Matrix ();
Matrix.postscale (Leftorright, 1, BMPW/2, BMPH/2);//The first two are XY transformations, the latter two are symmetric axis center points
Matrix.posttranslate (x, y);
Canvas.drawbitmap (bmpluffy[0], matrix, paint);
Method Two
Canvas.save ();
Canvas.scale ( -1, 1, x + bmpluffy[0].getwidth ()/2, Y + bmpluffy[0].getheight ()/2);
Canvas.drawbitmap (Bmpluffy[0], x, y, paint);
Canvas.restore ();
method One, using the matrix of the Way (3x3) matrix:
1, the first use Postscale way to the picture to point (BMPW/2,BMPH/2) as the center, to X=BMPW/2 for the axis of symmetry flip;
2. Use Posttranslate to move the picture to (x,y) coordinates
method Two, Canvas Flip (abbreviated)
Note the following questions:
For the BMPW and bmph is the width of the picture used, you need to use the picture Bmp.getwidth () and Bmp.getheight () to obtain,
You can't use the size that you see on your PC, otherwise there may be a mismatch!
-----------------------------------------------------------------------
If you don't know the matrix very well, you can refer to the API documentation, or the Web article