为什么在BMP图片中,像素的排布为BGR,而不是RGB?
这个问题长时间不太理解,直到最近受到好奇心驱使,到网上去查了一下,然后发现了一个答案,至于对不对,不敢保证,算是给了自己一个说法。
答案的来源是这里: 為啥BMP圖中象素的排列順序是BGR
其中网友回 whoishere 回复 :
MSDN中有说明啊,摘录给你看看:
Platform SDK: Windows GDI
COLORREF
The COLORREF value is used to specify an RGB color.
typedef DWORD COLORREF;
typedef DWORD *LPCOLORREF;
Remarks
When specifying an explicit RGB color, the COLORREF value has the following hexadecimal form:
0x00bbggrr
The low-order byte contains a value for the relative intensity of red; the second byte contains a value for green; and the third byte contains a value for blue. The high-order byte must be zero. The maximum value for a single byte is 0xFF.
To create a COLORREF color value, use the RGB macro. To extract the individual values for the red, green, and blue components of a color value, use the GetRValue, GetGValue, and GetBValue macros, respectively.
里面说: 一个RGB颜色的16进制值表示是: 0x00bbggrr ,在小端存储的模式下,读取到的顺序正好就是 rr gg bb 00, 也就是RGB的顺序。
所以,
结论是: 这里在保存的时候使用BGR顺序,是为了读取时候的方便。
当然,以上只是我的推测,如果有知道确切原因的,还请分享下,我好改正~~