How do you load PNGs on a C++ program?

Member
Posts: 249
Joined: 2008.10
Post: #1
Hi friends!


How do you load PNGs on a C++ program? Now I'm using LodePNG and it seems a bit slow. And if I use PVR it loads ultrafast, but quality is very bad (2d platform game).

I'd like to hear your suggestions about loading PNG files in C++ case (not ObjC).

Thanks.
Quote this message in a reply
Member
Posts: 166
Joined: 2009.04
Post: #2
Google for C++ image libraries ... there are quite a few.

Personally, I wrap everything in PVR files ( which can store uncompressed images as well).
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #3
Try SOIL!

I haven't actually tried it on iPhone, but I bet it'd work.
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #4
I use libpng. (C API, but equally applicable to C++)
Quote this message in a reply
Member
Posts: 249
Joined: 2008.10
Post: #5
warmi Wrote:Google for C++ image libraries ... there are quite a few.

Personally, I wrap everything in PVR files ( which can store uncompressed images as well).

I already did that, but result in a 2d platform game is horrible.

See this pictures. 1st uses PVR. 2nd uses PNG.
[Image: img0008gj.png]
[Image: img0043yr.png]


I also tried SOIL but it does not compile for iphone, there are too much errors.


"PVR files ( which can store uncompressed images as well)."
Mmmm.. Warmi , what do you think if I store my pngs inside a pvr? is it at least faster to load?
Can I use
RGBA 4444
RGB 565 in my PVR loader?
Quote this message in a reply
Member
Posts: 166
Joined: 2009.04
Post: #6
riruilo Wrote:I already did that, but result in a 2d platform game is horrible.

See this pictures. 1st uses PVR. 2nd uses PNG.
[Image: img0008gj.png]
[Image: img0043yr.png]


I also tried SOIL but it does not compile for iphone, there are too much errors.


"PVR files ( which can store uncompressed images as well)."
Mmmm.. Warmi , what do you think if I store my pngs inside a pvr? is it at least faster to load?
Can I use
RGBA 4444
RGB 565 in my PVR loader?

That's what I am doing ... the only downside is that uncompressed images are stored within PVRs well ... uncompressed ,which means a png which weights at 40 kb, will take 80 kb or so when stored within an uncompressed PVR file.

I get around that by having all my game data reside in a virtual file system within a zip file and it only matters in terms of disk storage because once the image gets loaded into an OpenGL buffer it doesn't matter.
Quote this message in a reply
Member
Posts: 446
Joined: 2002.09
Post: #7
riruilo Wrote:I also tried SOIL but it does not compile for iphone, there are too much errors.
I use SOIL's little brother STBI on the iPhone. Works great, but with either of these you need to configure them to exclude stuff that you don't need.

As far as slow-to-load goes, make sure you check load times on release builds. Debug builds can easily be 2X-3X slower for this sort of thing.
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #8
Frank C. Wrote:I use SOIL's little brother STBI on the iPhone. Works great, but with either of these you need to configure them to exclude stuff that you don't need.

Hey, cool, thanks I didn't know about that one! Smile
Quote this message in a reply
Nibbie
Posts: 4
Joined: 2008.11
Post: #9
i'd recommend openframeworks... super lightweight framework with a similar style to Processing..

http://www.openframeworks.cc/

loading PNGS, Gifs, JPGS, all super easy and one line of code..
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Unable to load textures wademcgillis 15 7,743 Apr 9, 2010 03:37 PM
Last Post: Macmenace
  iPhone pre-multiplied alpha (on PNGs) woes.. Jamie W 12 7,955 Feb 22, 2010 02:44 PM
Last Post: Frank C.
  How can I avoid XCODE transform my PNGs when moved to iPhone? riruilo 7 5,602 Apr 24, 2009 12:02 AM
Last Post: smallstepforman
  PNGs scaled smaller jeonghyunhan 0 1,781 Feb 10, 2009 06:04 PM
Last Post: jeonghyunhan