Hi All,
I am trying to load PNG with IMG_Load but I cannot find the function and the file SDL_images.h does not exist
Am I doing something bad or the function has been replaced with something new?
Thank,
Stefano
Hi All,
I am trying to load PNG with IMG_Load but I cannot find the function and the file SDL_images.h does not exist
Am I doing something bad or the function has been replaced with something new?
Thank,
Stefano
If you need help getting SDL_image installed, check out the lazyfoo tutorial → Lazy Foo' Productions - Extension Libraries and Loading Other Image Formats
After you get SDL_image installed and linked properly in your project, make sure to call IMG_Init(IMG_INIT_PNG | IMG_INIT_JPG);
To save some typing, if you are using SDL_Texture and the SDL_Renderer, check out
SDL_Texture * myTexture = IMG_LoadTexture(myRenderer, "pathToImage.png");
When you are done with it don’t forget to call the following to avoid memory leaks:
SDL_DestroyTexture(myTexture);
myTexture = NULL;
On exiting, call
IMG_Quit();
Actually, the lazyfoo tutorials will talk you through most of that in a more detailed and functional manner.
Note that the header file name is SDL_image.h without an s.
Thank you to all of you! The support is amazing! It seems that the tutorial that I am following do not mention SDL2_image as external libraries (or I missed the steps)…
I have downlaoded SDL2-devel-2.28.4-mingw.zip , updated the CMakeLists.txt manually from CLion, updated the code as suggested by @GuildedDoughnut added the dll to the build directory and it works!!!
Thank you!