Android Bitmap Zoom rotate watermark cropping operation

Source: Internet
Author: User

In Android, bitmap represents a picture that encapsulates the picture's information.

One, the picture is scaled.

(1) Get Bitmap object

Bitmap Bitmap = Bitmapfactory.decoderesource (Getresources (), r.drawable.a);

(2) Create matrix

Matrix matrix = new Matrix ();

Matrix.postscale (0.5f, 0.5f); Zoom 50%

(3) Create a new bitmap

Bitmap dstbmp = Bitmap.createbitmap (Bitmap, 0, 0, bitmap.getwidth (), Bitmap.getheight (), Matrix, false);

explain the above parameters Public static Bitmap CreateBitmap (Bitmap source, int x, int y, int width, int height, Matrix m, boolean filter)

Source this is the original image that needs to be scaled, and the Matrix object is used to specify the scale (which can also be rotated, expanded, and so on for other operations), and filter does not know what to do.

The 4 parameters of the x, y width,heigjt specify where to scale the original picture, such as a picture of 300x200 (width*height), then passing in 100, 100, 200, 100 means

Gray part scaling, from the original x axis of 100 pixels to the right 200 pixels from the y-axis 100 pixels down 100 pixels.

Android Bitmap Zoom rotate watermark cropping operation

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.