Android image Drawing (a) Multiple methods for image mirroring _android

Source: Internet
Author: User
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
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.