fstream and libpng
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]
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:
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.
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
Popular Topics
Advertisement