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

◆ decode() [1/3]

FramePtr fl::Jpeg::decode ( const JpegConfig & config,
fl::span< const fl::u8 > data,
fl::string * error_message = nullptr )
static

Definition at line 343 of file jpeg.cpp.hpp.

343 {
344 auto decoder = createDecoder(config);
345 auto stream = fl::make_shared<fl::memorybuf>(data.size());
346 stream->write(data);
347
348 if (!decoder->begin(stream)) {
349 if (error_message) {
350 decoder->hasError(error_message);
351 }
352 return nullptr;
353 }
354
355 DecodeResult result = decoder->decode();
357 if (error_message) {
358 decoder->hasError(error_message);
359 }
360 return nullptr;
361 }
362
363 Frame frame = decoder->getCurrentFrame();
364 return frame.isValid() ? fl::make_shared<Frame>(frame) : nullptr;
365}
static JpegDecoderPtr createDecoder(const JpegConfig &config)
Definition jpeg.cpp.hpp:372
constexpr fl::size size() const FL_NOEXCEPT
Definition span.h:458
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
Definition shared_ptr.h:414
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
DecodeResult
Definition idecoder.h:18

References createDecoder(), fl::Frame::isValid(), fl::make_shared(), fl::span< T, Extent >::size(), and fl::Success.

+ Here is the call graph for this function: