Bitmap the difference between Png jpg

Source: Internet
Author: User

Knowledge Popularization Series:

There are two scenarios in which images are used: One is the storage format on the hard disk, and the other is the expanded format of the memory.

One, in-memory pictures

Because you need to know all the information about the picture, all in memory, the picture is generally expanded. It's a transparent bitmap. Here are some concepts.

1. Pixel points: Color has r (Red red), G (green), B (blue blue) Three colors, and then consider the transparency value of the problem will have a (Alpha alpha value).

2. Bit depth: How many bits you need to represent a pixel point. If the bit depth is 32, each of the eight bits represents the R,g,b,a

As shown in the following illustration:

If fully expanded in memory, it occupies a memory size of: width pixels x High pixel points x bit depth/8 in bytes

Android in memory full expansion is the bitmap format, bitmap is the most primitive preservation of all the information, (generally not on the hard disk so save)

The resolution referred to in the picture is related to print scanning and is not generally concerned.

In the process of daily communication refers to the resolution generally refers to its width and height of the number of pixels.

Second, the picture on the hard disk

Pictures are a waste of space if they are stored in the same way as memory. For example, if a picture is all red, it is necessary to store each pixel point. It only needs to record its red and size just fine, in memory can be re-restored. The picture is generally compressed during transmission and storage.

1.PNG is a lossless compression. And with a transparency value. Compression is really limited.

2.JPG is a lossy compression with no transparent values (this is why the bit depth of the above figure is 24). Discard part of the information without affecting the use of the situation, the naked eye is generally indistinguishable.

Saving the same bitmap image as JPG is much smaller than saving it as PNG, which is why you use the most JPG images on the web.


Third, the display of the picture

Images are loaded from the hard drive into memory and are ultimately needed to be displayed to the user. The phone's screen also has a resolution (wide pixel points, high pixel points), for example, if there is a phone resolution of 800x1080, a picture of 1600x2160, full screen display of the picture, the picture will not be distorted.

Typically a control is used to display the picture, and whether the image is distorted is related to the size of the control (full fill).

In the case of the aspect ratio, the large picture is displayed in small controls, and the picture does not distort. Small pictures are displayed in large controls and the pictures are distorted.

In the case where the aspect ratio is not consistent, the picture must distort if the control is fully filled. Unless, maintain its proportions, not fully populated.

In the actual application process, in order to show the effect of better and save memory, generally need to get the size of the control in advance, when loading the picture, the picture is processed to the same size as the control.



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.