FastLED 3.10.8
Loading...
Searching...
No Matches
pixel.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/stl/int.h"
4#include "fl/stl/noexcept.h"
5namespace fl {
6
7// Color formats for decoded output
8enum class PixelFormat {
9 RGB565, // 16-bit RGB: RRRRR GGGGGG BBBBB
10 RGB888, // 24-bit RGB: RRRRRRRR GGGGGGGG BBBBBBBB
11 RGBA8888, // 32-bit RGBA: RRRRRRRR GGGGGGGG BBBBBBBB AAAAAAAA
12 YUV420, // YUV 4:2:0 format (mainly for internal use)
13 // Generic storage formats. These do not encode transfer function,
14 // primaries, component byte order, or any container wire identifier.
16 Rgb16 = 4,
17};
18
19// Calculate bytes per pixel for given format
21 switch (format) {
22 case PixelFormat::RGB565: return 2;
23 case PixelFormat::RGB888: return 3;
24 case PixelFormat::RGBA8888: return 4;
25 case PixelFormat::YUV420: return 1; // Simplified for luminance component
26 case PixelFormat::Rgb16: return 6;
27 default: return 0;
28 }
29}
30
31// Convert RGB565 to RGB888 with proper scaling to full 8-bit range using lookup tables
32void rgb565ToRgb888(fl::u16 rgb565, fl::u8& r, fl::u8& g, fl::u8& b) FL_NO_EXCEPT;
33
34// Convert RGB888 to RGB565
36 return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
37}
38
39} // namespace fl
unsigned char u8
Definition stdint.h:131
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
fl::string format(const char *fmt) FL_NO_EXCEPT
Format with no arguments.
Definition format.h:439
void rgb565ToRgb888(fl::u16 rgb565, fl::u8 &r, fl::u8 &g, fl::u8 &b) FL_NO_EXCEPT
Definition pixel.cpp.hpp:24
InputGamut g
Definition rgbw.h:125
fl::u16 rgb888ToRgb565(fl::u8 r, fl::u8 g, fl::u8 b) FL_NO_EXCEPT
Definition pixel.h:35
fl::u8 getBytesPerPixel(PixelFormat format) FL_NO_EXCEPT
Definition pixel.h:20
PixelFormat
Definition pixel.h:8
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_NO_EXCEPT