Pure boring technical paste, about the color depth, bit depth, the depth image Comments

Because of the recent contact with a bit embedded development, resources required picture formats and mobile and web developers difference from past contacts is relatively large, only the following article. It is more obscure, you can bypass the unwanted.

Image depth, color depth, bit depth of the Grand Unified

First of all clear that the image depth is the color depth Color Depth. Deep Color and bit depth Bit-depth, checked a lot of information, opinions, there is that color depth is the number of pixels used to store each bit, and bit depth descriptive attributes of the channel, that we usually refer to 24-bit True Color full-color and 16-bit color mode, here are the 24 and 16-bit color depth or deep? In fact need not tangle, collectively referred to as the depth. In the display parameters, a bit more of a concept of the Bit-depth deep. And specific relationship between the depth of color will be described in detail later.

Although the designer's eyes, PNG, BMP, JPG, JPEG, GIF bitmap images have a resolution of these attributes were all called bitmap can correspond to any scalable vector graphics, such as SVG, but the engineer, especially hardware engineer eyes, bitmap BMP format may specifically refers to, so be sure to confirm in advance and developers, especially when it comes to embedded development, even more so, the more the more trouble the more limited the bottom.

Principles of Computer images are stored

Because for the most commonly used PS software designers depth when saving BMP format option, so the following are an example to illustrate the BMP format, especially in PNG and JPEG are compressed, the specific compression principle is unknown, do not explain. Trace to its source, as only recognizes the binary language of computers, what is stored during image storage is it? pixel. 8px * 8px a picture, a total of 64 pixels, the computer at the time of storage, which will in turn be stored for 64 points. When saving a hex format into the image (which is burned into the MCU format required), opened with a text editor will find all the code string in hexadecimal, each string is a coded pixel here, encoding 64 after the stream analysis showing a different color, the final composition of the picture.

The value assigned to the channel bit depth

When storing BMP format, as shown, the system will prompt a depth of about, when we switch from the fundamental mode to the advanced mode, the option to see the specific 16-bit, 24-bit and 32-bit, (X or a) nRnGnBn RnGnBn or represented in the form, (n represents the bit value assigned to the channel). Since each channel only supports 256 (0-255) values, and therefore, the channel has a value not larger than 8 bits (256 is the eighth power of 2).

For a 16-bit representation RGB (5,6,5) described, R5G6B5, not the color value, but that the bit depth of 16-bit channel allocation method, R 5 supports power value 2 (32) value, G value supports 6 th power of 2 (64) values, B values ​​support 5 th power of 2 (32) values, if 16-bit is assigned to R8G8B0, but the composition of the final color, 65,536 colors will be missing blue elements, only red and green 65,536 combinations. Of course, this is very unreasonable, only to form a color combination of RGB, the average number of bits to be allocated to the R, G, B, and four transparent channel Alpha channel. These channels is disposed substantially common settings.

For Android developers, may not be familiar with, Bitmap ConfigARGB_8888, where the corresponding 24-bit X8R8G8B8, ARGB_4444 the corresponding 16-bit X4R4G4B4, RGB_565 the corresponding 16-bit deep R5G6B5, no transparency.

Therefore, the bit depth is 8-bit map, only a maximum of 8 power of 2, that is, 256 colors, far less than the color of the picture we need for embedded systems or industrial areas, the display will be 16 the following. When the bit depth of 16 bits, there are 16 colors support a power of 2, 65,536 colors, that is, we are talking about a high color. The GIF image format, it can only support 256 colors, which is why sometimes turn into a reason GIF distortion. Wherein the 32-bit and 24-bit RGB are on the same channel, but eight is used to save the Alpha channel. In other words, the color performance and non-discriminatory, but an increase of 8, or 8 power (256) 2-color gray-order, but the transition more natural colors, has come to the human eye can not recognize the difference degree.

PS to save in BMP format types, provides a 4-bit, 8-bit, 16-bit, 24-bit and 32-bit options, it's just common bit depth, 6 can you? Of course, possible for the six images can be assigned to different channels R2G2B2, a total of 4 * 4 * 4 supports a total of 64 different colors. Even a total of 100 * 100 ten thousand pixels of the picture, for 6 bits deep, it was only 64 colors to choose from. For example, our project, the display specifications of the chip support is clearly indicated the 6-bit, R supports four values ​​corresponding 0,1 / 3R, 2 / 3R and 1R, G supported by four values ​​corresponding 0,1 / 3G , 2 / 3G four values ​​and 1G, B supports a corresponding 0,1 / 3B, 2 / 3B and 1B. How to convert it designer can understand the language, red R, for example, in the RGB color representation can be set in the range 0-255, successively defining four values ​​would become (0,75,150 , 255), so that it is clear to see a lot during the color selection RGB (75,150,75) the color or RGB (0,75,150) and the like, as long as a combination of these four values ​​will it. The easiest way is to download as a 64-bit color palette.

Positively correlated bit depth and image size

Having a bit depth of distribution, we look at storage, which is the effect on the image size.

Byte bit bytes and bits

bit basic storage unit is a computer, a binary "0" or "1", and the memory unit as generally Byte. Conversion relationship exists Byte and bit, 1Byte = 8bit.

An 8-bit depth images stored bits per pixel is needed is how much? The deep meaning of bits, each pixel can store 8-bit binary, is a 'bit of each binary, therefore, it requires a pixel 8bit, i.e. 1Byte. And FIG. 16-bit color, each pixel is stored, is stored in 16-bit binary, to store one pixel is required 2Byte. Of course, because the computer while storing image information other than the head, such as bitmaps even storing pixel, bitmap information, palette, etc. (like txt file size of the text and not just inside the occupied bytes number), and therefore is not identical to the results of our conversion, if we can understand the reasons for the changes caused by different bit depths like picture size. For BMP format images, not bound colors, each dye spot, black white or gray color, storing the number of bytes occupied by the same, only the influence of the size of the bit depth. Below this picture, all the pictures of the resolution are 8 * 8 pixels, I plainly different suffixes to distinguish when exporting selected bit depth. It is apparent that, as long as the 16-bit deep gray matter, pure red, any of RGB color, or even gradients, are the same size when stored. And filled the same gray same picture resolution, the depth and saved as 32-bit depth, the 16-bit 24 with respect to the size of a step present on an increasing trend.

The PNG compression format that is subject to the richness of color. Contrast this picture can be well below illustrate the problem, the same is 256px * 256px image, a rich color, one of only two colors, choose PNG-24 at the same time, large differences in size, but also a 16-bit BMP bit depth, the same size.

to sum up

Depth understanding of the mechanisms affecting the picture bit depth of color, mainly in the face of specific projects, can be more flexible choose a more appropriate image format, as well as in the selection of colors, how to adapt to different display chip. Converting obscure part of the hardware resources required specification in reference to the design.

Reproduced in: https: //juejin.im/post/5d06e4e7f265da1b971a7438

Guess you like

Origin blog.csdn.net/weixin_33704591/article/details/93165523