FastLED 3.9.15
Loading...
Searching...
No Matches

◆ convertPixelsToRgb()

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

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

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

References fl::bit_cast(), fl::format(), 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: