IMG_GetAnim...ecoderFrame(3)
๐ IMG_GetAnimationDecoderFrame ๐
okay bestie, so this one lives in the SDL_image3 manual, in the FUNCTIONS section, and it's literally the little engine that could for pulling frames out of an animation. it's giving "next frame please" energy. ๐ฌโจ
๐ธ NAME ๐ธ
IMG_GetAnimationDecoderFrame โ get the next frame in an animation decoder. yes, the next one. one at a time. we are patient and we are slaying. ๐
๐ฆ SYNOPSIS ๐ฆ
#include <SDL3_image/SDL_image.h>
bool IMG_GetAnimationDecoderFrame(IMG_AnimationDecoder *decoder, SDL_Surface **frame, Uint64 *duration);
like. look at that signature. gorgeous. iconic. no notes. ๐ญ๐
โจ DESCRIPTION โจ
so basically? this function decodes the next frame in the animation decoder and hands it back to you as an SDL_Surface. that's it, that's the whole job, and it does it so well.
โ ๏ธ bestie listen: the surface it gives you is yours now, and you should free it with SDL_FreeSurface() when you're done with it. do not leave it lying around. that's a memory leak and we do not do those in this house. ๐ฎ๐
now here's the part you actually need to know, and it's a little sneaky. if the animation decoder has no more frames or an error happened while decoding, this function returns false. and like, both of those return false, so how do you tell them apart?? ๐ณ
you call SDL_GetError(). periodt.
- if
SDL_GetError()returns an empty string โ that means there are simply no more available frames. you've reached the end. the animation said "that's all folks". ๐ - if
SDL_GetError()returns a valid string โ that means the decoding actually failed. something went wrong. ๐จ
so yeah, don't just see false and panic โ check the error string, it will tell you which vibe you're in. ๐
๐ FUNCTION PARAMETERS ๐
decoderโ the animation decoder. the main character of this whole operation. ๐frameโ a pointer that gets filled in with theSDL_Surfacefor the next frame in the animation. it's an out-param, so it's gonna write the frame into your pointer. ๐ผ๏ธdurationโ the duration of the frame. usually this is in milliseconds, but ngl it can be other units if theIMG_PROP_ANIMATION_DECODER_CREATE_TIMEBASE_DENOMINATOR_NUMBERproperty is set when you create the decoder. so like, check your timebase before you assume. iykyk. โฑ๏ธ
๐ RETURN VALUE ๐
returns true on success. ๐ returns false on failure and also when no more frames are available. yeah. same value, two meanings, it's messy but we deal.
if you need more info, call IMG_GetAnimationDecoderStatus() or SDL_GetError(). they will fill you in. ๐ซถ
๐ AVAILABILITY ๐
this function is available since SDL_image 3.4.0. so if you're on anything older... bestie. upgrade. ๐ญ
๐ SEE ALSO ๐
IMG_CreateAnimationDecoder(3)IMG_CreateAnimationDecoder_IO(3)IMG_CreateAnimationDecoderWithProperties(3)IMG_GetAnimationDecoderStatus(3)IMG_ResetAnimationDecoder(3)IMG_CloseAnimationDecoder(3)
the whole friend group fr fr ๐ซ๐
and that's the page!! written by the SDL_image girlies, version SDL_image 3.4.8, and yeah it's giving classic manpage date energy but we're keeping it cute anyway. go decode some frames, bestie, you're gonna eat. ๐ โจ๐
๐ฆ where this page comes from
- fedora 43: SDL3_image-devel 3.4.8-1.fc43 ยท Zlib AND (HPND-Pbmplus AND Zlib) AND MIT AND (MIT OR Unlicense) AND LicenseRef-Fedora-Public-Domain
- fedora 43: SDL3_image-devel 3.4.8-1.fc43 ยท Zlib AND (HPND-Pbmplus AND Zlib) AND MIT AND (MIT OR Unlicense) AND LicenseRef-Fedora-Public-Domain
- fedora 44: SDL3_image-devel 3.4.8-1.fc44 ยท Zlib AND (HPND-Pbmplus AND Zlib) AND MIT AND (MIT OR Unlicense) AND LicenseRef-Fedora-Public-Domain
- fedora 44: SDL3_image-devel 3.4.8-1.fc44 ยท Zlib AND (HPND-Pbmplus AND Zlib) AND MIT AND (MIT OR Unlicense) AND LicenseRef-Fedora-Public-Domain
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms