Jump to content
  • Advertisement
Sign in to follow this  
Prune

fstream and libpng

This topic is 3551 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do I do it? The damn libpng uses a FILE *. Is there any way to get a compatible file pointer from an ifstream? [Edited by - Prune on October 27, 2008 11:54:00 AM]

Share this post


Link to post
Share on other sites
Advertisement
You have to write a new input source. It's all in the libpng docs.

Alternatively, I have a C++ wrapper that makes this incredibly easy. You can get the source code from here:

pngxx. You'll need this support library, too.

EDIT: you'll need Mercurial to get the code, at least until I release some zip files.

I haven't put together any docs yet (hopefully soon, though) but here's the basic idea:


std::vector<unsigned char> raster;
std::ifstream source("lalala.png"); // could be any istream

imagexx::raster_details d = pngxx::read_image(source, back_inserter(raster));

// Now query the details of the raster by looking at d





It also supports reading from an arbitrary input iterator pair, or you could give the filename directly. There are a bunch of iterator adaptors too, to allow you to read it in to any pre-existing image containers. Just ask if you want to know more.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!