Greetings fellow developers. I am in the process of adding support for animated GIFs to my existing module Computerscare Custom Blank. I found an implementation example online using stbi that I have successfully adapted to work in my module, but when I have multiple instances of Custom Blank, they all show the same GIF. I’ve confirmed that each module instance is trying to load a different GIF, I believe the problem is somewhere in the stbi_xload function defined here: https://github.com/freddyz/computerscare-vcv-modules/blob/customblank-gif/src/animatedGif.hpp
This is the module code:
I’m pretty ignorant about using pointers, and direct memory reading/writing in C++ (as this code does). Any ideas would be much appreciated! Thanks in advance.
You delete there some frame data or corrupt the image data somehow in your frames vector with stbi_image_free(img);. I commented this line out and then it works. I tried this on Windows and your original code immediately crashes Rack when loading a gif.
Yeah… I’m scared by it too. I mostly just copy/pasted that method from a gist I found and it worked so I decided it is a good starting point. Do you have any specific suggestions for how this can be improved related to memory management? Or any additional thoughts on what is problematic about this implementation?