Framebuffer/pixel depth/color depth/RGB565
1, framebuffer related.
Framebuffer's variable information refers to the length, width, and color depth of the framebuffer. The two command words are related to two structures: struct fb_fix_screeninfo and struct fb_var_screeninfo, both of which are relatively large, which are used to preserve the fixed information of the framebuffer device, The latter is used to save variable information for framebuffer devices. These two structures are used when calling IOCTL (). The following fields of struct fb_var_screeninfo are commonly used in the application: Xres, Yres, Bits_per_pixel, which represents the resolution of the x-axis, the resolution of the y-axis, and the color depth per pixel (the unit of color depth is bit/ Pixel), whose type definition is unsigned 32-bit integer numbers.
2, RGB-related.
For color images, each pixel is usually represented by three components, that is, R (Red), G (Green), B (Blue) three components, each of which is represented by a byte, so that each component takes a range of 0 to 255, and for grayscale images, each pixel is usually represented by a component A component is also represented by a byte, with a value range from 0 to 255.
3, framebuffer and RGB coordination.
Since the framebuffer device used has a color depth of 16 bits, color format is 5-6-5 format-that is, r (Red) occupies a height of 5 in the 16bit, G (green) occupies the middle 6 digits in 16bit, B (blue) occupies a low 5 in 16bit; for 24-bit RGB, Each byte represents a color component, so the conversion is as follows: for R-byte, 3-bit right, for G-byte, 2-bit right, for B-byte, 3-bit right, and then the right to move the value of stitching up, you get 16-bit color values. In a later program, the 24-bit color is called RGB888, and the 16-bit color value is called RGB565, which may not be canonical, but in any case, in this article, it is called
4, pixel depth
Pixel depth is the number of bits that are used to store each pixel, and it is also used to measure the resolution of the image. The pixel depth determines the possible number of colors for each pixel of the color image, or determines the level of gray levels that each pixel of the grayscale image may have. For example, each pixel of a color image is represented by a r,g,b three component, and if each component is in 8 bits, a pixel is represented by a total of 24 digits, which means that the pixel depth is 24, and each pixel can be one of the 16 777 216 (2) colors. In this sense, the pixel depth is often said to be image depth. The more bits that represent a pixel, the more colors it can express, and the deeper the depth.
Although the pixel depth or image depth can be very deep, but the various VGA color depth is limited. For example, Standard VGA supports color images of 4-bit 16 colors, and is recommended for at least 8-digit 256 colors in multimedia applications. Due to the limitations of the device and the resolution of the human eye, it is not always necessary to pursue a particularly deep pixel depth. In addition, the deeper the pixel depth, the greater the storage space occupied. Conversely, if the pixel depth is too shallow and that affects the quality of the image, the image looks rough and unnatural.
When the pixel of the color image is represented by a binary number, the R,g,b component is often represented by a fixed number of digits, and 1 bits or several bits are added as attributes. For example, when RGB 5:5:5 represents a pixel, it is represented by a total of 16 bits in 2 bytes, where the R,g,b each occupies 5 bits and the remaining one as a property bit. In this case, the pixel depth is 16 bits, and the image depth is 15 bits. A property bit is used to specify the nature of the pixel. For example, in a cd-i system, the pixel represented by RGB 5:5:5 is 16 bits, and its highest bit (B15) is used as an attribute bit, and it is called a transparent (transparency) bit, which is recorded as T. The meaning of T can be understood as follows: if there is already a picture on the display screen, when the picture or part of the picture overlaps on it, the T bit is used to control whether the original image can be seen. For example, to define T=1, the original image is completely invisible; t=0, the original image can be completely seen.
When a pixel is represented by 32 digits, if the r,g,b is represented by 8 bits, the remaining 8 bits are often called alpha channel (alpha channel) bits, or overlay (overlay) bit, interrupt bit, and attribute bit. Its usage can be illustrated with an example of a premultiplied alpha channel. If the four components of a pixel (a,r,g,b) are represented by a numeric value, the (A,R,G,B) is shown as red when (1,1,0,0). When the Pixel is (0.5,1,0,0), the result of the prefetch becomes (0.5,0.5,0,0), which means that the red intensity of the original pixel appears to be 1, and the red intensity now displayed is reduced by half.
It is useful in practice to define the attributes of a pixel in this way. For example, in a color image overlay text description, and do not want the text to cover the picture, you can use this method to define the pixel, and the color of the pixel display it is called a mixed color (key color). In the production of image products, digital TV images and computer-produced images are often mixed together, this technology is called View mixing (video keying) technology, it also uses the alpha channel.
5, color depth.
Color Depth is used to measure how much color information in an image can be used to display or print pixels, in units of bits, so that the color depth is sometimes called bit depth. The common color depth is 1-bit, 8-bit, 24-bit, and 32-bit. 1-bit has two possible values: 0 or 1. A larger color depth (more bits per pixel of information) means that the digital image has more available colors and more precise color representations.
Because a 1-bit image contains 2 colors, 1-bit images can be composed of up to two colors. In 1-bit images, the color of each pixel can only be black or white; a 8-bit image contains 256 colors, or 256 levels of gray, each pixel may be any of 256 colors; a 24-bit image contains 16.7 million (2^24) colors; A 32-bit image contains 2^32 colors, Rarely, however, this is because the 32-bit image may be a 24-bit image with an alpha channel or a CMYK color pattern image, both of which contain 4 8-bit channels. The image color mode and color depth are associated (an RGB image and a CMYK image can be 32 bits, but this is not always the case).
The following table lists the common color depth, the number of colors, and the color mode of the relationship.
Color depth Color Quantity color mode
1-bit 2 (black and white) bitmap
8-bit 256-indexed color
16-bit 65536 grayscale, 16 bits/channel
24-digit 16. 7 million RGB
32-bit CMYK, RGB
48-bit RGB, 16-bit/channel
32-bit images can also be black and white, so there are only two colors. -------------------------------------------------------------------------------
According to the BPP, modify the corresponding bit of video memory data.
The incoming color data is generally 32bit, which is the format: 0X00RRGGBB,
For 8PP, the palette index is implemented.
For 16PP, color conversion is required.
For 32PP, the size corresponds exactly.
This article learns about: framebuffer/pixel depth/color depth/RGB565
Supplementary content:
Computer Color Format (8-bit 16-bit 24-bit 32-bit color) framebuffer Display call driver content hundred ask the network LCD tutorial