Today, when I review the code, I found this macro definition: #define COLOR_TO_MTK_COLOR_SIMUL ((color >>) & 0x1f) << 11) \ | (((color) >> Ten & 0x3f) << 5) \ | ((color) >> 3) & 0x1f) Do you know what this macro is for? After careful analysis, the original is to realize the conversion of RGB888 to RGB565, access to relevant information, found that there is a network of cattle writing Dongdong, here and you share. Talk about quantitative compression and quantification compensation. In color format conversion, often encounter changes in the number of color quantization, such as from 24bit RGB888 to 16bit RGB565 color conversion. The so-called quantitative compression and quantification compensation are my personal concepts, now described below. Quantitative compression, for example: Conversion of 24bit RGB888-> 16bit RGB565 24IBT RGB888 R7 R6 R5 R4 R3 R2 R1 R0 G7 G6 G5 G4 G3 G2 G1 G0 B7 B6 B5 B4 B3 B2 B1 B0 16bit RGB656 R7 R6 R5 R4 R3 G7 G6 G5 G4 G3 G2 B7 B6 B5 B4 B3 Quantization digits from 8bit to 5bit or 6bit, take the high position of the original 8bit, the quantization of compression, but the loss of precision. Quantitative compensation, for example: Conversion of 16bit RGB565-> 24bit RGB888 16bit RGB656 R4 R3 R2 R1 R0 G5 G4 G3 G2 G1 G0 B4 B3 B2 B1 B0 24IBT RGB888 R4 R3 R2 R1 R0 0 0 0 G5 G4 G3 G2 G1 G0 0 0 B4 B3 B2 B1 B0 0 0 0 24IBT RGB888 R4 R3 R2 R1 R0 R2 R1 R0 G5 G4 G3 G2 G1 G0 G1 G0 B4 B3 B2 B1 B0 B2 B1 B0 Note: The second row of 24bit RGB888 data is converted, not compensated data, there will be loss in precision The third row of 24bit RGB888 data is a quantified compensation for the data, the low level of the quantitative compensation It is easy to prove that such a compensation method is a reasonable linear compensation. The principle of compensation is very simple, we think carefully about it, so no longer detailed description. To sum up: Quantization compression method: Three words to get high Methods of quantifying compensation: 1. Fill the original data to the high 2. For low, with the original data low to compensate 3. If there are still unfilled bits, continue to use the low level of the original data for circular compensation Explain the concept of cyclic compensation: Conversion of 8bit RGB332-> 24bit RGB888 8bit RGB332 R2 R1 R0 G2 G1 G0 B1 B0 24bit RGB888 R2 R1 R0 0 0 0 0 0 G2 G1 G0 0 0 0 0 B1 B0 0 0 0 0 0 0 24bit RGB888 R2 R1 R0 R2 R1 R0 0 0 G2 G1 G0 G2 G1 G0 0 0 B1 B0 B1 B0 0 0 0 0 24bit RGB888 R2 R1 R0 R2 R1 R0 R2 R1 G2 G1 G0 G2 G1 G0 G2 G1 B1 B0 B1 B0 B1 B0 0 0 24bit RGB888 R2 R1 R0 R2 R1 R0 R2 R1 G2 G1 G0 G2 G1 G0 G2 G1 B1 B0 B1 B0 B1 B0 B1 B0 See this, you should understand it is not the case, where the B component, the four-wheel compensation, to meet the requirements. The need for quantitative compensation, intuitively, I put forward this method of compensation is correct (because I do not have to prove the strict), to make such a compensation, in the color of all kinds of conversion, can significantly improve the color effect, reduce the loss of precision. |