我知道这个话题已经提出来了,但我从来没有从页面中得到任何东西。我的答案的一个线索是我需要将GIF分成每个帧,但是如何?一些代码以及这将非常感谢。 非常感谢。
答案 0 :(得分:2)
Use GIFLIB to read gif animations. GIFLIB provides a handy "slurp" function that reads the entire file into structs that you can then pretty easily retrieve your frames from. It's been a while but IIRC when building an SDL_Texture
from the one gif frame you will need to look up colors from a palette for each pixel. Since gifs don't have one fixed frame rate you will also need to store the individual delay times for each frame. Read this for a detailed description of the gif file format and it will help you make sense of GIFLIB.
That said, I would advise against using the clunky GIF format for cutscenes (and most other things) because it's pretty space hungry and you may have problems syncing up your audio nicely. I would recommend looking around for a way to play "real" video formats -- take a look at this project.