|
Boost Users : |
Subject: Re: [Boost-users] serialization of an dynamic array to read/write a image in xml
From: Markus Bader (bader_at_[hidden])
Date: 2009-09-29 11:44:27
Thanks all of you for your ideas and suggestions
I finally realized the serialize(archive& ar, const unsigned) funktion using
ar & make_nvp("data", make_binary_object(mpData, mWidth*mHeight);
but I have to say that the memory behind mpData bust be allocated
first on reading an image.
Finaly I endet up with
template<class archive>
void serialize(archive& ar, const unsigned int version) {
using boost::serialization::make_nvp;
using boost::serialization::make_binary_object;
if (archive::is_saving::value) {
ar & make_nvp("width", mWidth);
ar & make_nvp("height", mHeight);
ar & make_nvp("data", make_binary_object(mpData, mWidth*mHeight);
} else if (archive::is_loading::value)
int w, h;{
ar & make_nvp("width", w);
ar & make_nvp("height", h);
2009/9/25 Damien R <damien.rg_at_[hidden]>:
> Robert Ramey wrote:
>>
>> also you could try
>>
>> ar & make_nvp("data", binary_object(sizeof(mpData), & mpData))
>
> This code do not work for dynamic allocation of mpData.
> data_type * mpData = new data_type[MAX];
> sizeof(mpData) = sizeof(data_type *);
>
> but it will be fine if you have static allocation :
> data_type mpData[MAX];
> sizeof(mpData) = MAX * sizeof(data_type);
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
-- Dipl.-Ing. Markus Bader ACIN | AUTOMATION & CONTROL INSTITUTE INSTITUT FÜR AUTOMATISIERUNGS- & REGELUNGSTECHNIK TECHNISCHE UNIVERSITÄT WIEN Gußhausstraße 27-29 | 376. 1040 Wien DVR-Nummer: 0005886 Tel. +43 (0)1 58801 - 37664 Skype: markus.bader.at.work Fax. +43 (0)1 58801 - 37697 bader_at_[hidden] | www.acin.tuwien.ac.at
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net