Описание тега bgr
BGR is a way of representing a color in a concise number of bits, similar to RGB. An RGB color is stored with Blue occupying the least significant "area" (e.g. a byte in 32-/24-bit formats), Green the second least, and Red the third least. A BGR color is represented in a similar way - the order of areas is reversed: Red occupies the least significant area, Green the second (still), and Blue the third. Thus, the difference between RGB and BGR is byte order.
However, many graphics libraries choose, as an implementation detail, to treat colors as unsigned 32-bit integers internally, with the three (or four when alpha is included) components packed into the integer. On a little-endian machine such as an x86 processor, the integer 0x01020304
will actually be stored in memory as 0x04030201
, thus 0x00BBGGRR
will be stored as 0xRRGGBB00
.
The use of the term BGR (or BGRA) is a way for a graphics library to explain how the integer is logically ordered. This in turn means that code which directly accesses the color component bits can be made clearer and more readable, instead of expressing arbitrary access patterns.
- An example in the wild of the metaphor shear between RGB and BGR