|
TinyGPU
|
RGB color stored in 16-bit RGB565 format, byte-swapped from the conventional bit layout. More...
#include <RGB565.h>
Public Member Functions | |
| RGB565 ()=default | |
| Creates a black RGB565 color. | |
| RGB565 (uint8_t r, uint8_t g, uint8_t b) | |
| Creates a color from 8-bit red, green, and blue components. | |
| RGB565 (uint16_t packed) | |
| void | setValue (uint8_t r, uint8_t g, uint8_t b) |
| Sets the color from 8-bit red, green, and blue components. | |
| void | setValue (uint16_t packed) |
| uint8_t | getRed () const |
| Returns the red component expanded to 8 bits. | |
| uint8_t | getGreen () const |
| Returns the green component expanded to 8 bits. | |
| uint8_t | getBlue () const |
| Returns the blue component expanded to 8 bits. | |
| uint16_t | getValue () const |
| uint16_t | getValueSwapped () const |
Static Public Member Functions | |
| static RGB565 | fromRGB (uint8_t r, uint8_t g, uint8_t b) |
| static uint16_t | swapBytes (uint16_t v) |
| static uint8_t | size () |
| Returns size in bits. | |
Protected Attributes | |
| uint16_t | value = 0 |
RGB color stored in 16-bit RGB565 format, byte-swapped from the conventional bit layout.
The class provides conversion between 8-bit per channel RGB values and the packed 16-bit representation commonly used by embedded displays.
Storage note: value holds the two bytes of the conventional RGB565 packing (R:5 G:6 B:5, red in the high bits) swapped - i.e. exactly the byte order every SPI/QSPI panel driver in this codebase (DisplayDriverSPI, DisplayDriverQSPI) needs on the wire. That's the overwhelmingly common consumer, so getValue()/writeData() need no per-pixel swap. Anything that instead needs the conventional (native) bit layout - LVGL's own pixel buffer, SDL's SDL_PIXELFORMAT_RGB565 texture upload, or a file format like AVI/BMP that declares standard RGB565 bitmasks - must go through getValueSwapped() (or construct via the swapped packed value) to undo it.
|
inline |
Creates a color from 8-bit red, green, and blue components.
|
inlineexplicit |
Creates a color from a packed value already in this class's stored (byte-swapped) order - i.e. one that round-trips through getValue(). To decode a packed value in the conventional (native) bit layout instead - e.g. a raw pixel from LVGL's own buffer - byte-swap it first: RGB565(swapBytes(nativePacked)).
|
inlinestatic |
Creates a color from semantic red/green/blue intensities, regardless of this class's own constructor argument order. Prefer this in generic code that converts between pixel formats.
|
inline |
Returns the blue component expanded to 8 bits.
|
inline |
Returns the green component expanded to 8 bits.
|
inline |
Returns the red component expanded to 8 bits.
|
inline |
Returns the packed value in this class's stored (byte-swapped) order - i.e. wire-ready for DisplayDriverSPI/DisplayDriverQSPI with no further swap needed.
|
inline |
|
inline |
Sets the color from a packed value already in this class's stored (byte-swapped) order - see the constructor note above.
|
inline |
Sets the color from 8-bit red, green, and blue components.
|
inlinestatic |
Returns size in bits.
|
inlinestatic |
Byte-swaps a 16-bit value; used to convert between this class's stored (wire) order and the conventional (native) RGB565 bit layout.
|
protected |