MCPcopy Create free account
hub / github.com/FastLED/FastLED / processGif

Function processGif

examples/Codec/codec_processor.cpp:87–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85
86
87void processGif() {
88 Serial.println("\n=== Processing GIF ===");
89
90 if (!fl::Gif::isSupported()) {
91 Serial.println("GIF decoding not supported on this platform");
92 return;
93 }
94
95 // Copy data from PROGMEM to RAM
96 fl::vector<fl::u8> gifData(CodecData::sampleGifDataLength);
97 fl::memcopy(gifData.data(), CodecData::sampleGifData, CodecData::sampleGifDataLength);
98
99 // Configure GIF decoder
100 fl::GifConfig config;
101 config.mode = fl::GifConfig::SingleFrame;
102 config.format = fl::PixelFormat::RGB888;
103
104 // Create decoder
105 fl::string error_msg;
106 fl::shared_ptr<fl::IDecoder> decoder = fl::Gif::createDecoder(config, &error_msg);
107
108 if (!decoder) {
109 Serial.print("Failed to create GIF decoder: ");
110 Serial.println(error_msg.c_str());
111 return;
112 }
113
114 // Create byte stream from data
115 auto stream = fl::make_shared<fl::memorybuf>(gifData.size());
116 stream->write(gifData);
117
118 // Begin decoding
119 if (!decoder->begin(stream)) {
120 fl::string error;
121 decoder->hasError(&error);
122 Serial.print("Failed to begin GIF decoding: ");
123 Serial.println(error.c_str());
124 return;
125 }
126
127 // Decode first frame
128 fl::DecodeResult result = decoder->decode();
129
130 if (result == fl::DecodeResult::Success) {
131 fl::Frame frame = decoder->getCurrentFrame();
132 if (frame.isValid()) {
133 displayFrameOnLEDs(frame);
134 showDecodedMessage("GIF decoded successfully!");
135 } else {
136 Serial.println("Invalid GIF frame received");
137 }
138 } else {
139 fl::string error;
140 decoder->hasError(&error);
141 Serial.print("GIF frame decode error: ");
142 Serial.println(error.c_str());
143 }
144

Callers

nothing calls this directly

Calls 15

memcopyFunction · 0.85
displayFrameOnLEDsFunction · 0.85
showDecodedMessageFunction · 0.85
printlnMethod · 0.45
dataMethod · 0.45
printMethod · 0.45
c_strMethod · 0.45
sizeMethod · 0.45
writeMethod · 0.45
beginMethod · 0.45
hasErrorMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected