Android enables you to rotate, zoom in, and shrink the picture _android

Source: Internet
Author: User

This article describes the Android implementation of the rotation, zoom in, reduce the image of the method. Share to everyone for your reference, specific as follows:

Project needs to do a preview of the function of the picture

Originally conceived as a custom view, the OnDraw used to generate a new bitmap to magnify, shrink

But because the mobile phone memory is limited, after several times magnified, will be core off.

Directly after the selection of ImageView to complete this task, unfortunately, although not repeated generation bitmap led to the core, but ImageView size limit is the picture can not be magnified or magnified can only be in this area.

Finally selected to do with the drawable of course

Private drawable image;
private int picwidth;
private int picheight;
@Override
protected void OnDraw (Canvas Canvas) {
  super.ondraw (Canvas);
  Picture scaling uses picwidth,picheight to control
  int L = (getwidth ()-picwidth)/2;
  int r = (getwidth () + picwidth)/2;
  int t = (getheight ()-picheight)/2;
  int B = (getheight () + picheight)/2;
  Image.setbounds (L, T, R, b);
  Canvas.rotate (Rotatedegre, GetWidth ()/2, GetHeight ()/2); Rotate picture
  image.draw (canvas);
}

For more information on Android-related content readers can view the site: "Android graphics and image processing skills summary", "Android Development introduction and Advanced Course", "Android debugging techniques and common problems solution summary", " Android Multimedia How-to Summary (audio, video, audio, etc), summary of Android Basic components usage, Android View tips Summary, Android layout layout tips and a summary of Android controls usage

I hope this article will help you with the Android program.

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.