Sign in to follow this  

fstream and libpng

This topic is 3341 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

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

This topic is 3341 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this