fstream and libpng

Started by
0 comments, last by the_edd 15 years, 6 months ago
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]
"But who prays for Satan? Who, in eighteen centuries, has had the common humanity to pray for the one sinner that needed it most?" --Mark Twain

~~~~~~~~~~~~~~~Looking for a high-performance, easy to use, and lightweight math library? http://www.cmldev.net/ (note: I'm not associated with that project; just a user)
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 istreamimagexx::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.

This topic is closed to new replies.

Advertisement