![]() |
SDL_Image and PNG support | ![]() |
![]() |
SDL_Image and PNG support | ![]() |
Mason Wheeler
Guest
![]() |
![]() |
...huh? SDL_Image has had PNG support for years.
From: VernJensen Subject: [SDL] SDL_Image and PNG support I'm attempting to add PNG support to SDL_Image, but have so far been unsuccessful. Got the lpng155 package from the libpng page (http://www.libpng.org/pub/png/libpng.html), and modified the SDL_Image 1.2.10 (http://www.libsdl.org/projects/SDL_image/) Visual Studio project to have this linker flag: LOAD_PNG_DYNAMIC="libpng15.dll" That is because the DLL produced by the png155 package is named as above. I recompile the SDL_Image.dll and copy it to my project's Visual Studio Release and Debug folders. However, my test program still fails to load .png images, while .bmp load fine. (IMG_Load_RW returns NULL, while SDL_RWFromFile does indeed have a file pointer.) This seems to indicate that SDL_Image is still does not "know" it has PNG support available to it via libpng15.dll. Am I doing something wrong, in the way I'm trying to give SDL_Image access to PNG loading? _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
||||||||||
|
![]() |
Re: SDL_Image and PNG support | ![]() |
VernJensen
![]() |
![]() |
Hmm, you're right. Any thoughts on why it won't load PNGs then? If I modify the testsprite2 demo to use SDL_Image to load the file like so:
then it works fine as long as *file is "icon.bmp" but it fails when it's "icon.png". (And yes, I put an icon.png file in the Release and Debug directories.) Something that's made this difficult to debug for me though is that even with "icon.bmp" it won't find the file if I launch from within Visual Studio -- it only finds the file if I launch by double-clicking the executable directly. Likely this is because the default "home directory" is different when launched from within Visuual Studio. Any thoughts on what I need to do to correct this? Would be handy to have it work while running from within the debugger... -Vern |
||||||||||||||
|
![]() |
Re: SDL_Image and PNG support | ![]() |
VernJensen
![]() |
![]() |
Side question: the SDL_Image distribution contains a folder called "Graphics" that contains:
jpeg.dll libtiff-3.dll libpng12-0.dll zlib1.dll Do these need to be included in my app's distribution if I want access to those features, or are they "compiled into" the SDL_image.dll so that only SDL_image.dll is needed? |
||||||||||
|
![]() |
SDL_Image and PNG support | ![]() |
Vijay Varadan
Guest
![]() |
![]() |
You'll need these files as well. The easiest way to determine what files are needed would be to run depends.exe on your game executable. I also use the OUTPUT window to see what DLLs are loaded and from what location.
-Vijay On Wed, 02 Nov 2011 11:58:08 -0700, "VernJensen" wrote:
-- -------- Vijay VaradanSkype: vijayvaradan | USA: +1-206-849-3710 (C)India: +1-425-956-3326 (VOIP) | India: +91-99400-13652 (C)LinkedIn: http://linkd.in/qTORH7 | Blog: http://bit.ly/oQBwNlGoogle+: http://bit.ly/vijayplus | Facebook: http://on.fb.me/oF7dq9Twitter: http://bit.ly/qsiqrp Axham Corporation | Axham Technologies, LLPLinkedIn: http://linkd.in/nL9wNX | LinkedIn: http://linkd.in/odgEc9Website: http://axham.com | Facebook: http://on.fb.me/axhamgamesTwitter: http://bit.ly/mPaDwB |
||||||||||||
|
![]() |
Re: SDL_Image and PNG support | ![]() |
VernJensen
![]() |
![]() |
Thanks Vijay. Just figured that out, as I got it working by re-installing an unmodified SDL_Image with its origianl PNG support. My PNGs are finally loading! Yeay. :-)
Only question remaining then is why it works when launching the .exe directly, but not when running from within Visual Studio. How do I "fix the path" when running from within Visual Studio so it finds the data files in the correct location? (Well I guess that's kinda off-topic...) |
||||||||||
|
![]() |
SDL_Image and PNG support | ![]() |
Patrick Baggett
Guest
![]() |
![]() |
You're looking for the so-called "Working Directory". It is an option in Project Properties->Debugging.
On Wed, Nov 2, 2011 at 2:07 PM, VernJensen wrote:
|
||||||||||||
|
![]() |
SDL_Image and PNG support | ![]() |
Vijay Varadan
Guest
![]() |
![]() |
Why not just use IMG_Load( file )?
Also, when you run the application in the debugger, the default VS behavior is to set the working directory to be the base project directory. I think it's coz the typical layout will be like this for a distributed app: app.exe |- subdir1 |- resource1 |- resource2 |- subdir1 |- resource1 |- resource2 To get the same effect, simply run the game executable from the project directory like this: C:\MyGameSolution\MyGameProject>.\debug\mygame.exe That way you don't have to keep copying files from the project root or its subdirectories into the output directory. This is better than either of the 2 alternatives of copying files into the debug directory or copying the game.exe to the project directory. Ideally, you'd change your project to build intermediates and final output files to directories outside your source tree and as a post build step copy your assets to the final output location. -Vijay On Wed, 02 Nov 2011 11:53:01 -0700, "VernJensen" wrote:
|
||||||||||||
|
![]() |
Re: SDL_Image and PNG support | ![]() |
VernJensen
![]() |
![]() |
Thanks! Fixed the working directory, and now it works like a charm. Yeay. :-)
It has to do with an SDL-based game engine I'm attempting to get up and running on Windows. It uses the other method for various reasons, hence why I wanted my test program to use the same exact method. Thanks so much for the help everyone! -Vern |
||||||||||||||
|