• Advertisement
Sign in to follow this  

Serializing an image archive in C++

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

There are a few places in my code where I have both images and some associated data where currently I save the images to png files and save the data separately. (This is ofr things like animations and tilesets). I think this could be simpler if I could save a single file with all the data packaged up but I'm not sure how to do this. I'm using boost serialization for my files which I'm very happy with so far. It's easy enough to save and load the bytes for each image, the only problem is that I lose out on any compression. One way around this is to try and find a way to get lib_png to save the compressed data to a buffer instead of a file, but it's not very clear how to do this. I also thought there might be libraries for applying compression to the file as a whole, but I'm also having trouble researching this. This might be a simpler solution depending on how hard the library is to set up and get it working with boost, but in any case would the results be much worse than using something specifically for images?

Share this post


Link to post
Share on other sites
Advertisement
Boost.IOStreams has a zlib and bzip compressing functionality.

Depending on what you're doing exactly, this might provide a simple way to compress all your data, including your rasters.

Or, I have a wrapper around libpng that makes it possible to save a png to an std::ostream or an output iterator e.g a stringstream or back_insert_iterator -- a buffer in other words.

Share this post


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

  • Advertisement