FastLED 3.9.15
Loading...
Searching...
No Matches
gif.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/codec/common.h" // IWYU pragma: keep
4#include "fl/stl/vector.h" // IWYU pragma: keep
5#include "fl/stl/shared_ptr.h" // IWYU pragma: keep
6#include "fl/stl/noexcept.h"
7
8namespace fl {
9
10// GIF metadata information structure
11struct GifInfo {
12 fl::u16 width = 0; // Image width in pixels
13 fl::u16 height = 0; // Image height in pixels
14 fl::u32 frameCount = 0; // Number of frames (1 for static, >1 for animated)
15 fl::u32 loopCount = 0; // Animation loop count (0 = infinite)
16 fl::u8 bitsPerPixel = 0; // Color depth (typically 8)
17 bool isAnimated = false; // True if GIF has multiple frames
18 bool isValid = false; // True if metadata was successfully parsed
19
20 GifInfo() FL_NOEXCEPT = default;
21
22 // Constructor for easy initialization
23 GifInfo(fl::u16 w, fl::u16 h, fl::u32 frames, fl::u32 loops = 0)
24 : width(w), height(h), frameCount(frames), loopCount(loops)
25 , isAnimated(frames > 1), isValid(true) {}
26};
27
28// GIF-specific configuration
40
41// GIF decoder factory
42class Gif {
43public:
44 // Create a GIF decoder for the current platform
45 static IDecoderPtr createDecoder(const GifConfig& config, fl::string* error_message = nullptr);
46
47 // Create a GIF decoder with default config (Streaming, RGB888)
48 static IDecoderPtr createDecoder(fl::string* error_message = nullptr) {
49 GifConfig config; // Uses defaults
50 return createDecoder(config, error_message);
51 }
52
53 // Check if GIF decoding is supported on this platform
54 static bool isSupported();
55
56 // Parse GIF metadata from byte data without creating a decoder
57 // This is a fast, lightweight operation that only reads the GIF header
58 static GifInfo parseGifInfo(fl::span<const fl::u8> data, fl::string* error_message = nullptr);
59};
60
61} // namespace fl
static GifInfo parseGifInfo(fl::span< const fl::u8 > data, fl::string *error_message=nullptr)
Definition gif.cpp.hpp:28
static IDecoderPtr createDecoder(const GifConfig &config, fl::string *error_message=nullptr)
Definition gif.cpp.hpp:9
static bool isSupported()
Definition gif.cpp.hpp:23
static IDecoderPtr createDecoder(fl::string *error_message=nullptr)
Definition gif.h:48
Definition gif.h:42
unsigned char u8
Definition s16x16x4.h:132
PixelFormat
Definition pixel.h:7
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_NOEXCEPT
GifConfig() FL_NOEXCEPT=default
@ Streaming
Definition gif.h:30
@ SingleFrame
Definition gif.h:30
PixelFormat format
Definition gif.h:33
fl::u8 bufferFrames
Definition gif.h:34
FrameMode mode
Definition gif.h:32
fl::u16 height
Definition gif.h:13
fl::u32 loopCount
Definition gif.h:15
bool isValid
Definition gif.h:18
GifInfo() FL_NOEXCEPT=default
bool isAnimated
Definition gif.h:17
fl::u8 bitsPerPixel
Definition gif.h:16
fl::u32 frameCount
Definition gif.h:14
fl::u16 width
Definition gif.h:12