There are many ways to create image images in Android. Today we are learning!The two methods are as follows:
// Method 1 matrix = new matrix (); matrix. postscale (leftorright, 1, bmp w/2, bmp h/2); // the first two are XY transformations, and the last two are the matrix of the symmetric axis center. posttranslate (x, y); canvas. drawbitmap (bmpluffy [0], matrix, paint); // method 2 // 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 1: Use the matrix method (3x3) matrix: 1. Use the postscale method to center the image with points (bmp w/2, bmp h/2, use x = bmp w/2 as the axis of symmetry to flip. 2. Use posttranslate to move the image to the (x, y) Coordinate Method 2. Flip the canvas (omitted)
Note the following: For the bmp w and bmp h refer to the width and height of the image, the image BMP must be used. getwidth () and BMP. getheight () is obtained. The size displayed on the PC cannot be used. Otherwise, misplacement may occur! ------------------------------------------------------------------------- If you are not familiar with matrix, you can refer to the API documentation or network articles related to matrix.