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

◆ convertBitmapToFrame()

fl::shared_ptr< fl::Frame > fl::third_party::SoftwareGifDecoder::convertBitmapToFrame ( nsgif_bitmap_t * bitmap)
private

Definition at line 277 of file software_decoder.cpp.hpp.

277 {
278 if (!bitmap) {
279 setError("convertBitmapToFrame called with null bitmap");
280 return nullptr;
281 }
282
283 GifBitmap* gifBitmap = static_cast<GifBitmap*>(bitmap);
284
285 // Validate bitmap data
286 if (!gifBitmap->pixels || gifBitmap->width == 0 || gifBitmap->height == 0) {
287 setError("GIF bitmap has invalid data or dimensions");
288 return nullptr;
289 }
290
291 fl::u8* rawData = gifBitmap->pixels.get();
292
293 // Since libnsgif outputs RGBA8888, we need to handle the conversion properly
294 // The Frame constructor expects the format we specify (outputFormat_)
295 // but libnsgif always gives us RGBA8888 data
296
297 // Create Frame with RGBA8888 format since that's what libnsgif provides
298 // The Frame constructor will handle conversion to outputFormat_ via convertPixelsToRgb
299 auto frame = fl::make_shared<fl::Frame>(
300 rawData,
301 gifBitmap->width,
302 gifBitmap->height,
303 fl::PixelFormat::RGBA8888, // What libnsgif actually provides
304 currentFrameIndex_ // Use frame index as timestamp
305 );
306
307 if (!frame || !frame->isValid()) {
308 setError("Failed to create valid Frame from GIF bitmap");
309 return nullptr;
310 }
311
312 return frame;
313}
void setError(const fl::string &message) FL_NOEXCEPT
unsigned char u8
Definition coder.h:132
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
Definition shared_ptr.h:414

References currentFrameIndex_, FL_NOEXCEPT, fl::unique_ptr< T, Deleter >::get(), fl::third_party::GifBitmap::height, fl::make_shared(), fl::third_party::GifBitmap::pixels, fl::RGBA8888, setError(), and fl::third_party::GifBitmap::width.

Referenced by decode().

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