
Hi All, Im not sure if this the correct mailing list or not.. in fact im not sure if i'm even going about this the right way.. forums are so much easier.. Im using the boost::serialization library, im attempting to serialize an image file from the freeimage library. It is working beautifully if i serialize to a text archive however, binary archives fail to load with a "stream error" exception. With the freeimage library i can save the image to memory and then retrieve the pointer to the start memory address and also retrieve the size. With this information I attempt the following (NOTE, "io" is the freeimage memory stream (fipMemoryIO) which is returning the memory pointer and the size): void save(Archive & ar, const unsigned int version) const { BYTE * pData; DWORD dwSize; io.acquire(&pData1, &dwSize); ar & dwSize; boost::serialization::array<BYTE> ao = boost::serialization::make_array<BYTE>(pData, dwSize); ar & ao; } void load(Archive & ar, const unsigned int version) { BYTE * pData; DWORD dwSize; ar & dwSize; pData = new BYTE[dwSize]; boost::serialization::array<BYTE> ao = boost::serialization::make_array<BYTE>(pData, dwSize); ar & ao; // <----------- This throws an exception } The above throws the exception.. even though it succeeds with a text archive. What is even more frustrating is that if (when saving) the contents pData1 points to are changed, when loading there is no exception. (Obviously the bitmap would be corrupt but thats beside the point). void save(Archive & ar, const unsigned int version) const { BYTE * pData; DWORD dwSize; io.acquire(&pData1, &dwSize); ar & dwSize; memset(pData1, 0xAB, dwSize); // <--- Add this line an no exception is thrown. boost::serialization::array<BYTE> ao = boost::serialization::make_array<BYTE>(pData, dwSize); ar & ao; } I am at a loss. If i want to write x number of bytes it should write x number of bytes no matter what those bytes are.. I must be doing something wrong because this just doesnt make sense. The exception is always thrown in basic_binary_iprimitve.hpp if(scount != s) boost::serialization::throw_exception( archive_exception(archive_exception::stream_error) ); Regards, Dan