This commit is contained in:
Miloslav Ciz 2025-03-12 16:58:53 +01:00
parent 5dbd5b164a
commit 53bd3b4b91
14 changed files with 1966 additions and 1937 deletions

View file

@ -1,10 +1,10 @@
# RGB565
RGB565 is color format, or a way of representing [colors](color.md) with just 2 [bytes](byte.md) (unlike traditional 24 bit RGB formats that use 3 bytes, one for each component), that is 16 [bits](bit.md) (giving a total of 65536 distinct colors), by using 5 bits (highest) for red, 6 bits for green (to which human eye is most sensitive) and 5 bits for blue; it can also be seen as a color [palette](palette.md). It is similar to [RGB332](rgb332.md) -- it's basically a mid way between RGB332 and full 24bit RGB against which it saves one byte per pixel, but compared to RGB332 [byte sex](byte_sex.md) comes to play here. Practically speaking you will rarely need anything more than this, 65 thousand colors are absolutely sufficient for everything.
RGB565 is [color](color.md) format, or a way of representing color with just 2 [bytes](byte.md) (unlike traditional 24 bit RGB formats that use 3 bytes, one for each component), that is 16 [bits](bit.md) (giving a total of [65536](65536.md) distinct colors), by using 5 bits (highest) for red, 6 bits for green (to which human eye is most sensitive) and 5 bits for blue; it can also be seen as a color [palette](palette.md). It is similar to [RGB332](rgb332.md) -- it's basically a mid way between RGB332 and full 24bit RGB against which it saves one byte per pixel, but compared to RGB332 [byte sex](byte_sex.md) comes to play here. Practically speaking you will rarely need anything more than this, 65 thousand colors are absolutely sufficient for everything.
Yet another similar format to this one is [RGB555](rgb555.md) which sacrifices one useful bit for gaining the nice property of having the same size of each component. The one "wasted" bit may also be utilized, e.g. for marking transparency.
Yet another similar format to this one is [RGB555](rgb555.md) which sacrifices one useful bit for gaining the nice property of having the same size of each component. The one "wasted" bit may also be utilized, e.g. for marking transparency. Variants of RGB565 can also be obtained by [swapping](permutation.md) the order of components, e.g. BGR565 etc.
Here is a [C](c.md) code for the basic conversions to/from this format:
Here is a [C](c.md) code for the basic conversions to/from RGB565:
```
unsigned int rgbTo565(unsigned char red, unsigned char green,