The pixel color data was recently read from a local 16-bit bitmap and populated with Android bitmap data. found that the use of Cavas when the screen display, the color of the photo display is not correct, found a lot of information, the original found two reasons:
1. The color component mask of the bitmap is mistaken, when Bitmapinfoheader.bicompression is Bi_bitfields, the bitmap is a 565-format bitmap, where the mask is stored in the original palette, The bitmap that is currently read bitmapinfoheader.bicompression is Bi_rgb, when the bitmap should be a bitmap of 555, so the mask should be masked with RGB555 data.
2. When converting RGB555 bitmap color data to RGB888 data, the bitmap's data pixel values and color component masks are first and foremost, and then because RGB555 is a lossy compression encoding of the color data, only 5 bits of data are left, and when the original data is converted to 8 bits, Data compensation is required, and can be used by default 0 for insufficient bit compensation to achieve the original color component length of 8 bits, there is a kind of argument. Is the use of a few 5-bit data to fill the data, it is said that the effect is better, less distortion.
Bibitcount=16 indicates that the bitmap has a maximum of 216 colors. Each pigment is represented by 16 bits (2 bytes). Such a format is called high-color, or enhanced 16-bit color, or 64K color.
It's more complicated, and when the value of the Bicompression member is BI_RGB, it doesn't have a palette.
In 16-bit. The lowest 5 bits represent the blue component, the middle 5 bits represent the green component, the high 5 bits represent the red component, the total is 15 bits, the highest one is reserved. Set to 0.
Such a format is also known as a 555 16-bit bitmap. Assuming that the value of the Bicompression member is Bi_bitfields, then the situation is complicated, first of all the position of the original palette is occupied by three DWORD variables, called Red, green, and blue masks.
It is used to describe the position of the red, green and blue components in 16 bits respectively. In Windows 95 (or 98). The system accepts bit fields in two formats: 555 and 565, and in the 555 format, the red, green, and blue masks are: 0x7c00, 0x03e0, 0x001f, and in the 565 format. They were: 0xf800, 0x07e0, 0x001f. After you have read a pixel, you can use the mask "and" on the pixel value respectively to extract the desired color component (and, of course, the appropriate left and right moves). In NT systems, there is no format limit. Just require that there is no overlap between the masks. (Note: The image in this format is more cumbersome to use, just because its display effect is close to the true color.) And the image data is much smaller than the true color image, so, it is used in many other games software.
Copyright notice: This article blog original article. Blogs, without consent, may not be reproduced.
RGB565 and RGB555 flags identify bitmap file formats