Android Image Rendering (I)-image problems

Source: Internet
Author: User

There are many ways to create image images in android. Today we are learning!
The two methods are as follows:
[Java]
// Method 1
Matrix 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 center points of the symmetric axis.
Matrix. 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 a matrix (3x3) matrix:
1. First, use postScale to take the image as the center (bmp w/2, bmp h/2) and x = bmp w/2 as the axis of symmetry;
2. Use postTranslate to move the image to the (x, y) coordinate.
Method 2: Flip the canvas (omitted)

Note the following:
For the values of bmp W and bmp H, the width and height of the image must be obtained using bmp. getWidth () and bmp. getHeight,
You cannot use the size shown on the PC. Otherwise, misplacement may occur!
-----------------------------------------------------------------------


From Akai's column

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.