[SOLVED][SDL/LIBPNG] Noob here.

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
xiphirx
Chaos Rift Junior
Chaos Rift Junior
Posts: 324
Joined: Mon Mar 22, 2010 3:15 pm
Current Project: ******** (Unkown for the time being)
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Contact:

[SOLVED][SDL/LIBPNG] Noob here.

Post 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. :(
Last edited by xiphirx on Thu Mar 25, 2010 11:24 am, edited 1 time in total.
StarCraft II Zerg Strategy, open to all levels of players!

Looking for paid work :< Contact me if you are interested in creating a website, need a web design, or anything else you think I'm capable of :)
User avatar
rolland
Chaos Rift Regular
Chaos Rift Regular
Posts: 127
Joined: Fri Dec 21, 2007 2:27 pm
Current Project: Starting an Android app soon
Favorite Gaming Platforms: PS1, N64
Programming Language of Choice: C++
Location: Michigan, US

Re: [SDL/LIBPNG] Noob here.

Post 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.
I'll write a signature once I get some creativity and inspiration...
User avatar
Maevik
Chaos Rift Junior
Chaos Rift Junior
Posts: 230
Joined: Mon Mar 02, 2009 3:22 pm
Current Project: www.keedepictions.com/Pewpew/
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Location: Long Beach, CA

Re: [SDL/LIBPNG] Noob here.

Post 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?
My love is like a Haddoken, it's downright fierce!
User avatar
MrDeathNote
ES Beta Backer
ES Beta Backer
Posts: 594
Joined: Sun Oct 11, 2009 9:57 am
Current Project: cocos2d-x project
Favorite Gaming Platforms: SNES, Sega Megadrive, XBox 360
Programming Language of Choice: C/++
Location: Belfast, Ireland
Contact:

Re: [SDL/LIBPNG] Noob here.

Post 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.
http://www.youtube.com/user/MrDeathNote1988

Image
Image

"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup
User avatar
xiphirx
Chaos Rift Junior
Chaos Rift Junior
Posts: 324
Joined: Mon Mar 22, 2010 3:15 pm
Current Project: ******** (Unkown for the time being)
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Contact:

Re: [SDL/LIBPNG] Noob here.

Post 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...
StarCraft II Zerg Strategy, open to all levels of players!

Looking for paid work :< Contact me if you are interested in creating a website, need a web design, or anything else you think I'm capable of :)
User avatar
MrDeathNote
ES Beta Backer
ES Beta Backer
Posts: 594
Joined: Sun Oct 11, 2009 9:57 am
Current Project: cocos2d-x project
Favorite Gaming Platforms: SNES, Sega Megadrive, XBox 360
Programming Language of Choice: C/++
Location: Belfast, Ireland
Contact:

Re: [SDL/LIBPNG] Noob here.

Post 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.
http://www.youtube.com/user/MrDeathNote1988

Image
Image

"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup
User avatar
xiphirx
Chaos Rift Junior
Chaos Rift Junior
Posts: 324
Joined: Mon Mar 22, 2010 3:15 pm
Current Project: ******** (Unkown for the time being)
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Contact:

Re: [SDL/LIBPNG] Noob here.

Post by xiphirx »

Yes, I am allowing the user to add tiles as they build the map.
StarCraft II Zerg Strategy, open to all levels of players!

Looking for paid work :< Contact me if you are interested in creating a website, need a web design, or anything else you think I'm capable of :)
User avatar
xiphirx
Chaos Rift Junior
Chaos Rift Junior
Posts: 324
Joined: Mon Mar 22, 2010 3:15 pm
Current Project: ******** (Unkown for the time being)
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Contact:

Re: [SDL/LIBPNG] Noob here.

Post 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
StarCraft II Zerg Strategy, open to all levels of players!

Looking for paid work :< Contact me if you are interested in creating a website, need a web design, or anything else you think I'm capable of :)
User avatar
hurstshifter
ES Beta Backer
ES Beta Backer
Posts: 713
Joined: Mon Jun 08, 2009 8:33 pm
Favorite Gaming Platforms: SNES
Programming Language of Choice: C/++
Location: Boston, MA
Contact:

Re: [SDL/LIBPNG] Noob here.

Post 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
"Time is an illusion. Lunchtime, doubly so."
http://www.thenerdnight.com
User avatar
xiphirx
Chaos Rift Junior
Chaos Rift Junior
Posts: 324
Joined: Mon Mar 22, 2010 3:15 pm
Current Project: ******** (Unkown for the time being)
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Contact:

Re: [SDL/LIBPNG] Noob here.

Post by xiphirx »

lol, I'm on to my next roadblock, rotating specific parts of a surface :(
StarCraft II Zerg Strategy, open to all levels of players!

Looking for paid work :< Contact me if you are interested in creating a website, need a web design, or anything else you think I'm capable of :)
User avatar
MrDeathNote
ES Beta Backer
ES Beta Backer
Posts: 594
Joined: Sun Oct 11, 2009 9:57 am
Current Project: cocos2d-x project
Favorite Gaming Platforms: SNES, Sega Megadrive, XBox 360
Programming Language of Choice: C/++
Location: Belfast, Ireland
Contact:

Re: [SDL/LIBPNG] Noob here.

Post 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:
http://www.youtube.com/user/MrDeathNote1988

Image
Image

"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup
Post Reply