1.1.3 large image display

Source: Internet
Author: User

Loading and displaying an image has a significant impact on memory usage. For example, the HTC G1 phone carries a 3.2 million-pixel camera. Cameras with 3.2 million pixels usually capture 2048x1536 pixels. Displaying a 32-bit image of this size will require memory of more than 663kb or about 13 MB. Although our applications may not necessarily exhaust the memory, this will certainly make the memory more easily exhausted.

Android provides an application class named bitmapfactory, which provides a series of static methods that allow loading bitmap images from various sources. For our needs, images will be loaded from the file and displayed in the initial activity. Fortunately, the available methods in bitmapfactory call the bitmapfactory. Options class, which allows us to define how bitmap is read into memory. Specifically, when loading an image, you can set the sampling size that bitmapfactory should use. Specify the insamlpesize parameter in bitmapfactory. options, which indicates the proportion of the bitmap image to be loaded. For example, here we set insamlpesize to 8, which will produce an image of 1/8 size of the original image.

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.