| 141 | } |
| 142 | |
| 143 | void Frame::convertPixelsToRgb(fl::u8* pixels, PixelFormat format) { |
| 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 | } |
| 163 | case PixelFormat::RGBA8888: { |
| 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 | } |
| 189 | |
| 190 | |
| 191 | } // namespace fl |
nothing calls this directly
no test coverage detected