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

◆ nsgif_frame_decode()

nsgif_error fl::third_party::nsgif_frame_decode ( nsgif_t * gif,
fl::u32 frame,
nsgif_bitmap_t ** bitmap )

Decodes a GIF frame.

Parameters
[in]gifThe nsgif_t object.
[in]frameThe frame number to decode.
[out]bitmapOn success, returns pointer to the client-allocated, nsgif-owned client bitmap structure.
Returns
NSGIF_OK on success, or appropriate error otherwise.

Definition at line 1953 of file gif.cpp.hpp.

1957{
1958 fl::u32 start_frame;
1959 nsgif_error ret = NSGIF_OK;
1960
1961 if (frame >= gif->info.frame_count) {
1962 return NSGIF_ERR_BAD_FRAME;
1963 }
1964
1965 if (gif->decoded_frame == frame) {
1966 *bitmap = gif->frame_image;
1967 return NSGIF_OK;
1968
1969 } else if (gif->decoded_frame >= frame ||
1971 /* Can skip to first frame or restart. */
1972 start_frame = 0;
1973 } else {
1974 start_frame = nsgif__frame_next(
1975 gif, false, gif->decoded_frame);
1976 }
1977
1978 for (fl::u32 f = start_frame; f <= frame; f++) {
1979 ret = nsgif__process_frame(gif, f, true);
1980 if (ret != NSGIF_OK) {
1981 return ret;
1982 }
1983 }
1984
1985 *bitmap = gif->frame_image;
1986 return ret;
1987}
nsgif_error
LibNSGIF return codes.
Definition nsgif.hpp:58
@ NSGIF_ERR_BAD_FRAME
Frame number is not valid.
Definition nsgif.hpp:77
@ NSGIF_OK
Success.
Definition nsgif.hpp:62
static fl::u32 nsgif__frame_next(const nsgif_t *gif, bool partial, fl::u32 frame) FL_NOEXCEPT
Definition gif.cpp.hpp:1819
static nsgif_error nsgif__process_frame(struct nsgif *gif, fl::u32 frame_idx, bool decode) FL_NOEXCEPT
Attempts to initialise the next frame.
Definition gif.cpp.hpp:1323
nsgif_bitmap_t * frame_image
currently decoded image; stored as bitmap from bitmap_create callback
Definition gif.cpp.hpp:86
fl::u32 decoded_frame
current frame decoded to bitmap
Definition gif.cpp.hpp:83
fl::u32 frame_count
number of frames decoded
Definition nsgif.hpp:388
struct nsgif_info info
Definition gif.cpp.hpp:72
#define NSGIF_FRAME_INVALID
Internal flag that a frame is invalid/unprocessed.
Definition gif.cpp.hpp:162

References FL_NOEXCEPT, nsgif__frame_next(), nsgif__process_frame(), NSGIF_ERR_BAD_FRAME, NSGIF_FRAME_INVALID, and NSGIF_OK.

Referenced by fl::third_party::SoftwareGifDecoder::decode().

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