Android Image zoom out and zoom matrix

Source: Internet
Author: User

/**bitmap Amplification Method */
private static Bitmap big (Bitmap Bitmap) {
Matrix matrix = new Matrix ();
Matrix.postscale (1.5f,1.5f); Ratio of long and wide magnification reduction
Bitmap resizebmp = Bitmap.createbitmap (Bitmap,0,0,bitmap.getwidth (), Bitmap.getheight (), matrix,true);
return resizebmp;
}
/**bitmap Reduction Method */
private static Bitmap Small (Bitmap Bitmap) {
Matrix matrix = new Matrix ();
Matrix.postscale (0.8f,0.8f); Ratio of long and wide magnification reduction
Bitmap resizebmp = Bitmap.createbitmap (Bitmap,0,0,bitmap.getwidth (), Bitmap.getheight (), matrix,true);
return resizebmp;
}

Drawing pictures
int savecount = Canvas.getsavecount ();
Canvas.save ();
Canvas.translate (Pleft, ptop); Canvas Brush Start position
if (Item.matrix! = null) {
Canvas.concat (Item.matrix); Adding matrix matrices to the canvas
}
Set the area where the graph is drawn, and the drawing area parameters of the picture will be zoomed in and out with the scale of the matrix parameter, for example, if the drawing starting point is 100px and matrix.scale=0.5
The drawing start point in the actual drawing is at 50px.
Canvas.cliprect (Item.rect);
Draw three Photos
The draw start position in Canvas.drawbitmap () zooms in and out with the scale of the matrix parameter, for example, if the drawing starting point is 100px at the same time matrix.scale=0.5
The drawing start point in the actual drawing is at 50px.
Canvas.drawbitmap (Item.bitmap,
Item.rect.left, Item.rect.top, Mpaint);
Canvas.restoretocount (Savecount);

Android Image zoom out and zoom matrix

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.