-bitmap.config,jpeg compression and size of image processing

Source: Internet
Author: User

Understanding of argb_8888, Alpha_8, argb_4444, rgb_565

A: Transparency

R: Red

G: Green

B: Blue

Bitmap.config argb_4444: Four bits per pixel, which is a=4,r=4,g=4,b=4, then one pixel takes up 4+4+4+4=16 bit.

Bitmap.config argb_8888: Four bits per pixel, which is a=8,r=8,g=8,b=8, then one pixel takes up 8+8+8+8=32 bit.

Bitmap.config rgb_565: Four bits per pixel, i.e. r=5,g=6,b=5, no transparency, then one pixel occupies 5+6+5=16 bit

Bitmap.config Alpha_8: Four bits per pixel, only transparency, no color.

In general, we are using the argb_8888, so that it is the most memory, because one pixel accounted for 32 bits, 8 bits = 1 bytes, so a pixel accounted for 4 bytes of memory. Suppose you have a picture of 480x800, and if the format is argb_8888, it will take up 480x800x4/1024=1525kb memory.

For JPEG, the compression ratio of the image compressed into this format, the compression ratio is usually between 10:1 to 40:1, the greater the compression ratio, the lower the quality; Conversely, the smaller the compression ratio, the better the quality. For example, you can put 1. 37Mb BMP bitmap File is compressed to 20. 3KB.

In fact, because the JPEG format is lossy compression format, so the same size of the picture, even if the parameters are identical, the size of the save is very different, so only the maximum and minimum value can be estimated, cannot calculate the output size without actual input.

When estimating, the main factors of influence include the following points (may not be complete, but generally sufficient):

    1. Image pixel Size

    2. Number of colors--affects the number of bytes per pixel after decompression

    3. Quality-grade 11, 0 o'clock the most obvious changes in the picture, the volume is also the smallest, the main effect of compression rate;

      Level 8 is generally a more recommended grade, no comparison of the situation can not see the quality of the loss

      Some software is mapped in percent form, some software starting from 1 so the maximum is 12

    4. Color Distribution--this has a large effect on compression, whether it is close to the minimum value of the valuation or the maximum value of the valuation is almost affected by him, is to cause no accurate value only the largest variable valuation

    5. As for the baseline, the difference, whether continuous optimization, the final volume is affected, but compared to the quality of the compression ratio in the picture is not particularly small impact can be ignored

With these simple theories, we'll talk about how to estimate and error size.

      1. The first is the image pixel size and color number, we can figure out the volume of the picture in memory

        Size=width * Height * bytes per pixel

        Here is a good understanding of the number of bytes per pixel, do not understand can Baidu, here to a few commonly used , the photo is generally the first:
        RGB (888)-3 bytes, RGB (565)-2 bytes, 256 colors-1 bytes, 16 colors -1/2 bytes, black and white -1/8 bytes

      2. After the compression rate range based on quality and picture size

        This is more complex, only empirical valuations, here are only a few variables of the image compression rate:

        a.  picture The smaller the compression rate, and gradually toward the current quality of the minimum compression ratio,
            Picture The larger the compression rate, And gradually tend to the current quality of the maximum compression rate,

             picture is likely to be smaller than 1 hours;

        b.  The lower the compression rate, the higher the 0 level will typically float between 200:1 and 30:1, mostly centered at 60 : 1 nearby

                                                8 levels typically fluctuate between 40:1 and 4:1, mostly in 16:1

                        &N Bsp                     11 levels typically float between 16:1 and 2:1, mostly around 7:1

        c.  The more color distribution tends to be monochrome, continuous color, repetition of color blocks, the higher the compression ratio, extreme (such as pure white figure), even if the picture is large, the picture will only have hundreds of bytes to dozens of K bytes.

         

        3. So the range of file sizes is the size that was obtained in the previous step * estimated compression range

-bitmap.config,jpeg compression and size of picture processing

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.