Home > Java > javaTutorial > body text

Introduction to various methods of image mirroring in android development

Y2J
Release: 2017-04-22 10:06:45
Original
2203 people have browsed it

There are many ways to do image mirroring in android. I learned it today. Friends who are interested can refer to

The two methods are as follows:

The code is as follows:

//Method one

Matrix matrix = new Matrix(); 
matrix.postScale(leftOrRight, 1, bmpW/2, bmpH/2);//前两个是xy变换,后两个是对称轴中心点 
matrix.postTranslate(x, y); 
canvas.drawBitmap(bmpLuffy[0], matrix, paint);
Copy after login

//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();
Copy after login

Method one, using matrix (3x3 ) Matrix:
1. First use postScale to flip the image with the point (bmpW/2, bmpH/2) as the center and x=bmpW/2 as the symmetry axis;
2. Use postTranslate , move the picture to (x, y) coordinates
Method 2, flip the canvas (omitted)
Pay attention to the following issues:
For bmpW and bmpH refer to the width of the picture used High, you need to use the image bmp.getWidth() and bmp.getHeight() to obtain it.
Cannot use the size seen on the PC, otherwise misalignment may occur!

The above is the detailed content of Introduction to various methods of image mirroring in android development. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!