Android bitmap Summary

Source: Internet
Author: User

I recently used the bitmap class and encountered many difficulties. I wrote it down and shared it with my friends who encountered the same difficulties.

1. If you want to upload an image to the server, the speed of calling Sina's interface is different from that of Sina's own upload. After finding the reason for one day, I found that Sina compresses the image:

Bitmap. Compress (bitmap. compressformat. JPEG, 100, baos );

The first parameter is the format of the compressed image. In particular, when the quality of the compressed image is the same, the compressed image in JPEG format is much smaller than that in PNG. Therefore, JPEG is recommended for compression.

The second parameter is that the quality of the compressed image is 0-100. 0 indicates that the image quality is the least compressed, and 100 indicates that the image quality is the maximum after compression.

The third parameter is the output stream at which point the image is compressed.

2. two common methods of Bitmap

Proportional Scaling:
Bitmap = bitmap. createscaledbitmap (bitmap, width, height, false );

Part of the screenshot:
Bitmap = bitmap. createbitmap (bitmap, X, Y, width, height );

3. It is also a fatal problem that memory overflow must be recycled when bitmap is not used.

If (Bitmap! = NULL &&! Bitmap.Isrecycled ())
){

Bitmap. Recycle ();

Bitmap = NULL;

}

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.