Thank you for the tip and for all the time you have spent helping me. I really appreciate it. Since we use the IplImage from a 3:rd party library I would like to try every possible work-around before forking of the library source (and having to maintain it) by adding member functions. But in the end, I might be forced to do just that. In that case I'll try your solution bellow. For now, I'll keep working to find some workaround using free functions. Best Regards, Anders Sundman Robert Ramey skrev:
Looking at this I might make one more small adjustment:
Robert Ramey wrote:
try something like the following:
#include <fstream> #include
#include #include #include class _IplImage { public: friend boost::serialization::access; int roi, width, height, depth, nChannels; int imageSize; int * imageData; template<class Archive> void save(Archive & ar, const unsigned int version) const { ar << roi << width << height << depth << nChannels; ar << imageSize; ar << boost::serialization::binary_object(imageData, imageSize); } template<class Archive> void load(Archive & ar, const unsigned int version){ ar >> roi >> width >> height >> depth >> nChannels; ar >> imageSize; imageData = CreateImageData(roi, width, height, depth, nChannels, imageSize); ar >> boost::serialization::binary_object(imageData, imageSize); } BOOST_SERIALIZATION_SPLIT_MEMBER() };
main(int argc, char *argv[]){ const _IplImage i; { std::ofstream os("test"); boost::archive::text_oarchive oa(os); oa << i; } _IplImage new_i; { std::ifstream is("test"); boost::archive::text_iarchive ia(is); ia >> new_i; } // compare the new and old images }
This compiles w/o issue on my system.
Robert Ramey