Problems getting SDL2_image to load jpgs and pngs

I’m having problems getting SDL2_image to load jpgs and pngs (but it loads bmps fine).

Here is exactly what I am doing:
I am using MS Visual Studio 2008 and my OS is Windows XP, SP 2.

Step 1: Getting SDL

On 2/12/13, I used HG to get SDL via “hg clone http://hg.libsdl.org/SDL”.
I put this folder at C:\Libraries\SDL.
I opened C:\Libraries\SDL\VisualC\SDL_VS2008.sln. I set the active target to Release, and built the SDL2 project. It gives me an error “Cannot open include file: ‘dxsdkver.h’”. This error is removed by adding “C:\Program Files\Microsoft DirectX SDK (June 2010)\Include” to the project’s C/C++ General Additional Include Directories. And then SDL2 builds fine. SDL2Main is also built fine.

Step 2: Getting SDL_image

Then, also on 2/12/13, I used HG to get SDL_image via “hg clone http://hg.libsdl.org/SDL_image”. I saved this to C:\Libraries\SDL_image. I opened C:\Libraries\SDL_image\VisualC\SDL_image.sln. I set the active target to Release. In the SDL2_image project’s C/C++ General Additional Include Directories, I added “C:\Libraries\SDL\include”. Then, to the project’s Linker General section, I added to the Additional Library Directories “C:\Libraries\SDL\VisualC\SDL\Release” so it could find SDL2.lib. And then SDL2_image builds fine.

Step 3: Building showimage.exe

To the showimage project, like before I added references to “C:\Libraries\SDL\include” and “C:\Libraries\SDL\VisualC\SDL\Release”. I also added to the project’s C/C++ General Additional Include Directories a reference to “C:\Libraries\SDL\VisualC\SDLmain\Release” so it could find SDL2main.lib. And showimage.exe builds fine.

To run showimage.exe, adjacent to the exe I added SDL2.dll and SDL2_image.dll (which I built in step 1 and 2). As far as I’m aware, showimage.exe should be working fine now. I add 3 test images (a .bmp, a .jpg, and a .png). In the command prompt, I navigate to C:\Libraries\SDL_image\VisualC\showimage\Release\showimage.exe and I run it such as “showimage.exe TestBMP.bmp”, “showimage.exe TestJPG.jpg”, and “showimage.exe TestPNG.png”.

Loading a .bmp works fine, but any .jpg or .png fails to load. Though showimage.cpp uses IMG_LoadTexture, IMG_Load also fails to load .jpgs or .pngs. My guess is I missed a simple step to enable jpgs and pngs, but I can’t seem to figure out what it is.

Does anyone know what I’m doing wrong?
Thanks in advance.

SDL_image loads libpng and libjpeg dynamically. Maybe you don’t have the
right dlls there with your program?

Jonny DOn Tue, Feb 12, 2013 at 7:04 PM, Trev wrote:

**
I’m having problems getting SDL2_image to load jpgs and pngs (but it loads
bmps fine).

Here is exactly what I am doing:
I am using MS Visual Studio 2008 and my OS is Windows XP, SP 2.

Step 1: Getting SDL

Quote:

On 2/12/13, I used HG to get SDL via “hg clone http://hg.libsdl.org/SDL”.
I put this folder at C:\Libraries\SDL.
I opened C:\Libraries\SDL\VisualC\SDL_VS2008.sln. I set the active target
to Release, and built the SDL2 project. It gives me an error “Cannot open
include file: ‘dxsdkver.h’”. This error is removed by adding “C:\Program
Files\Microsoft DirectX SDK (June 2010)\Include” to the project’s C/C++
General Additional Include Directories. And then SDL2 builds fine. SDL2Main
is also built fine.

Step 2: Getting SDL_image

Quote:

Then, also on 2/12/13, I used HG to get SDL_image via “hg clone
http://hg.libsdl.org/SDL_image”. I saved this to C:\Libraries\SDL_image.
I opened C:\Libraries\SDL_image\VisualC\SDL_image.sln. I set the active
target to Release. In the SDL2_image project’s C/C++ General Additional
Include Directories, I added “C:\Libraries\SDL\include”. Then, to the
project’s Linker General section, I added to the Additional Library
Directories “C:\Libraries\SDL\VisualC\SDL\Release” so it could find
SDL2.lib. And then SDL2_image builds fine.

Step 3: Building showimage.exe

Quote:

To the showimage project, like before I added references to
"C:\Libraries\SDL\include" and “C:\Libraries\SDL\VisualC\SDL\Release”. I
also added to the project’s C/C++ General Additional Include Directories a
reference to “C:\Libraries\SDL\VisualC\SDLmain\Release” so it could find
SDL2main.lib. And showimage.exe builds fine.

To run showimage.exe, adjacent to the exe I added SDL2.dll and
SDL2_image.dll (which I built in step 1 and 2). As far as I’m aware,
showimage.exe should be working fine now. I add 3 test images (a .bmp, a
.jpg, and a .png). In the command prompt, I navigate to
C:\Libraries\SDL_image\VisualC\showimage\Release\showimage.exe and I run it
such as “showimage.exe TestBMP.bmp”, “showimage.exe TestJPG.jpg”, and
"showimage.exe TestPNG.png".

Loading a .bmp works fine, but any .jpg or .png fails to load. Though
showimage.cpp uses IMG_LoadTexture, IMG_Load also fails to load .jpgs or
.pngs. My guess is I missed a simple step to enable jpgs and pngs, but I
can’t seem to figure out what it is.

Does anyone know what I’m doing wrong?
Thanks in advance.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

You’re missing some dlls. Put all the dlls in there and try again.
Then read the manual.

Bruce

– Sent from my meager, humble desktop computer.

bruce.bowman tds.net wrote:

You’re missing some dlls. Put all the dlls in there and try again.
Then read the manual.

Bruce
I forgot to mention that. I DID add the DLLs, but in retrospect, the ones I added were named like jpeg.dll and although these are dlls that worked for me previously, they didn’t work for me now.
I decided to redownload the dlls at your urging, and this time I obtained them from http://www.libsdl.org/projects/SDL_image/release/SDL_image-1.2.12-win32.zip. I added libjpeg-8.dll, libpng15-15.dll, libtiff-5.dll, libwebp-2.dll, and zlib1.dll.

And it worked.

Thanks, Johnny D and Bruce.