Page 1 of 1

[SOLVED][SDL/LIBPNG] Noob here.

Posted: Mon Mar 22, 2010 3:29 pm
by xiphirx
Hey,

I'm new here, but I have been following you (the team) on YouTube for quite some time. I have been programming a map editor in C++/SDL and have come to the point where I need to save my map data. My map data consists of a map.txt file (no problem creating it) and a tile.png. I know that SDL does not have built in functions to save PNG's, and seeing how I am not very good in C++ or writing filetype savers for the matter, I went on a google hunt for a function. I have found it at http://encelo.netsons.org/_download/savesurf.tar.gz .
I have downloaded that, included pngfuncs.c and pngfuncs.h into my project, and tried to build my project. Of course it failed because I did not have libpng in my includes. So, I went and got libpng, compiled it (first time compiling a package, but I don't think I failed D:), and included it into my project, etc. I built my project this time and everything went well. Upon launching my application, and attempting to save my map, I encountered this

Code: Select all

libpng: warning: Application was compiled with png.h from libpng-1.0.5
libpng: warning: Application  is  running with png.c from libpng-1.2.29
libpng: error: Incompatible libpng version in application and library
libpng error: Incompatible libpng version in application and library
Soo, I decided to research on this issue, and found this http://www.libpng.org/pub/png/pngfaq.html#mismatch .

I checked my headers and libs, and they are all at version 1.2.29, I even replaced the libpng.dll in my application directory, but that message still pops up.
I honestly don't know what to do now. :(

Re: [SDL/LIBPNG] Noob here.

Posted: Mon Mar 22, 2010 3:38 pm
by rolland
If you're using SDL, why not just add SDL_image? http://www.libsdl.org/projects/SDL_image/
EDIT:
Oh, and welcome to the forums. We have cookies.

Re: [SDL/LIBPNG] Noob here.

Posted: Mon Mar 22, 2010 4:28 pm
by Maevik
Is it possible that you have an older version of png.h in your OS' system folder that the linker is accessing before it looks in the project folder?

Re: [SDL/LIBPNG] Noob here.

Posted: Mon Mar 22, 2010 4:33 pm
by MrDeathNote
rolland wrote:If you're using SDL, why not just add SDL_image? http://www.libsdl.org/projects/SDL_image/
EDIT:
Oh, and welcome to the forums. We have cookies.
^This, libpng requires other files to be in your project folder such as jpeg.dll, zlib1.dll and SDL_image.dll, try this: http://www.lazyfoo.net/SDL_tutorials/lesson03/index.php. Lazyfoo shows you how to set up SDL_image in great detail.

Re: [SDL/LIBPNG] Noob here.

Posted: Mon Mar 22, 2010 7:40 pm
by xiphirx
rolland wrote:If you're using SDL, why not just add SDL_image? http://www.libsdl.org/projects/SDL_image/
EDIT:
Oh, and welcome to the forums. We have cookies.
I already have SDL_image, but it doesn't save PNG's, it just loads them.... unless I am dumb D:
Is it possible that you have an older version of png.h in your OS' system folder that the linker is accessing before it looks in the project folder?
I don't think so since this is the first time I used libpng...

Re: [SDL/LIBPNG] Noob here.

Posted: Tue Mar 23, 2010 3:48 am
by MrDeathNote
xiphirx wrote:
rolland wrote:If you're using SDL, why not just add SDL_image? http://www.libsdl.org/projects/SDL_image/
EDIT:
Oh, and welcome to the forums. We have cookies.
I already have SDL_image, but it doesn't save PNG's, it just loads them.... unless I am dumb D:
Is it possible that you have an older version of png.h in your OS' system folder that the linker is accessing before it looks in the project folder?
I don't think so since this is the first time I used libpng...
I don't really see why you need to save the image, are you changing the tilesheet in some way during the map editing process? Otherwise you could just copy/move the original tilesheet to the map file location.

Re: [SDL/LIBPNG] Noob here.

Posted: Tue Mar 23, 2010 11:58 am
by xiphirx
Yes, I am allowing the user to add tiles as they build the map.

Re: [SDL/LIBPNG] Noob here.

Posted: Tue Mar 23, 2010 1:01 pm
by xiphirx
Double-Posting for update:

Well gee.. this is embarrassing :(
I figured out that I put the old png.h in my project directory, and VS used that instead of the one in my include directory...

It saves PNGs now, but the colors are a bit messed up... I'm going to try and remedy that...

EDIT: fixed! Thanks all

Re: [SDL/LIBPNG] Noob here.

Posted: Tue Mar 23, 2010 1:13 pm
by hurstshifter
xiphirx wrote: Well gee.. this is embarrassing :(
I figured out that I put the old png.h in my project directory, and VS used that instead of the one in my include directory...
Image


jk, glad you fixed it

Re: [SDL/LIBPNG] Noob here.

Posted: Tue Mar 23, 2010 1:58 pm
by xiphirx
lol, I'm on to my next roadblock, rotating specific parts of a surface :(

Re: [SDL/LIBPNG] Noob here.

Posted: Tue Mar 23, 2010 6:12 pm
by MrDeathNote
xiphirx wrote:lol, I'm on to my next roadblock, rotating specific parts of a surface :(
Glad you fixed it, i saw a post on gamedev that was about the colors being messed up and there was a solution too, guess im a bit late though :lol: