FastLED 3.10.8
Loading...
Searching...
No Matches

◆ convertPixelsToRgb()

void fl::Frame::convertPixelsToRgb ( fl::u8 * pixels,
PixelFormat format )
private

Definition at line 141 of file frame.cpp.hpp.

141 {
142 CRGB* rgbData = mRgb.data();
143
144 switch (format) {
145 case PixelFormat::RGB888: {
146 for (size_t i = 0; i < mPixelsCount; i++) {
147 fl::u8* pixel = &pixels[i * 3];
148 rgbData[i] = CRGB(pixel[0], pixel[1], pixel[2]);
149 }
150 break;
151 }
152 case PixelFormat::RGB565: {
153 fl::u16* pixel565 = fl::bit_cast<fl::u16*>(pixels);
154 for (size_t i = 0; i < mPixelsCount; i++) {
155 fl::u8 r, g, b;
156 rgb565ToRgb888(pixel565[i], r, g, b);
157 rgbData[i] = CRGB(r, g, b);
158 }
159 break;
160 }
162 for (size_t i = 0; i < mPixelsCount; i++) {
163 fl::u8* pixel = &pixels[i * 4];
164 rgbData[i] = CRGB(pixel[0], pixel[1], pixel[2]);
165 // Ignoring alpha channel for now
166 }
167 break;
168 }
169 case PixelFormat::YUV420: {
170 // Basic YUV420 to RGB conversion - simplified implementation
171 // For now, just use the Y (luminance) component as grayscale
172 for (size_t i = 0; i < mPixelsCount; i++) {
173 fl::u8 y = pixels[i];
174 rgbData[i] = CRGB(y, y, y);
175 }
176 break;
177 }
178 default: {
179 // Fallback: fill with black
180 if (mPixelsCount > 0 && !mRgb.empty()) {
181 fl::memset((u8*)rgbData, 0, mPixelsCount * sizeof(CRGB));
182 }
183 break;
184 }
185 }
186}
fl::vector_psram< CRGB > mRgb
Definition frame.h:65
const size_t mPixelsCount
Definition frame.h:64
unsigned char u8
Definition stdint.h:131
fl::CRGB CRGB
Definition video.h:18
fl::string format(const char *fmt) FL_NO_EXCEPT
Format with no arguments.
Definition format.h:439
FASTLED_FORCE_INLINE void * memset(void *s, int c, size_t n) FL_NO_EXCEPT
Definition cstring.h:148
void rgb565ToRgb888(fl::u16 rgb565, fl::u8 &r, fl::u8 &g, fl::u8 &b) FL_NO_EXCEPT
Definition pixel.cpp.hpp:24
To bit_cast(const From &from) FL_NO_EXCEPT
Definition bit_cast.h:48
InputGamut g
Definition rgbw.h:125

References fl::bit_cast(), fl::FL_NO_EXCEPT, fl::format(), fl::g, fl::memset(), mPixelsCount, mRgb, fl::RGB565, fl::rgb565ToRgb888(), fl::RGB888, fl::RGBA8888, fl::y, and fl::YUV420.

Referenced by Frame().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: