Sign in to follow this  
Somnia

Serializing an image archive in C++

Recommended Posts

Somnia    122
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
the_edd    2109
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

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