best way to serialize a GIL image

int width = 200; int height = 200; rgb8_image_t img(width,height); unsigned char* buffer = interleaved_view_get_raw_data(view(img)); FILE* fd = fopen(path,"wb"); fprintf(fd, "P6\n# CREATOR: unknown\n%d %d\n255\n",width,height); fwrite(buffer,1,width*height*3,fd); fclose(fd); GIL is just a wrapper around your buffer. No direct serialization support is provided nor needed.

An important note: Using \n in a PPM file under windows, if in text mode, will give you problems because the LF will be interpreted as pixel data. 2009/3/25 Tom Brinkman <reportbase@gmail.com>:
int width = 200; int height = 200; rgb8_image_t img(width,height); unsigned char* buffer = interleaved_view_get_raw_data(view(img));
FILE* fd = fopen(path,"wb"); fprintf(fd, "P6\n# CREATOR: unknown\n%d %d\n255\n",width,height); fwrite(buffer,1,width*height*3,fd); fclose(fd);
GIL is just a wrapper around your buffer. No direct serialization support is provided nor needed. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Tom Brinkman wrote:
int width = 200; int height = 200; rgb8_image_t img(width,height); unsigned char* buffer = interleaved_view_get_raw_data(view(img));
FILE* fd = fopen(path,"wb"); fprintf(fd, "P6\n# CREATOR: unknown\n%d %d\n255\n",width,height); fwrite(buffer,1,width*height*3,fd); fclose(fd);
GIL is just a wrapper around your buffer. No direct serialization support is provided nor needed. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
My question wasn't about how to write a GIL image to a file, it was about the most efficient way to serialize it to a boost archive. The class that owns the GIL image in my case also has other state and the entire class instance needs to be serializable. Obviously I can get the raw data and serialize that out, but when reading in from the archive wouldn't I have to read it in to a temporary buffer and then use that buffer to reconstruct the GIL image? I'd rather not perform extra copies of pixel data like that if I don't have to.

Kenny Riddile wrote:
My question wasn't about how to write a GIL image to a file, it was about the most efficient way to serialize it to a boost archive. The class that owns the GIL image in my case also has other state and the entire class instance needs to be serializable. Obviously I can get the raw data and serialize that out, but when reading in from the archive wouldn't I have to read it in to a temporary buffer and then use that buffer to reconstruct the GIL image? I'd rather not perform extra copies of pixel data like that if I don't have to.
In recent versions of Boost, a save_array function is available. This might be the most efficient way to do it. However, I don't know what needs to be done when deserializing so you should look into it more :-) -- Sohail Somani http://uint32t.blogspot.com

Kenny Riddile wrote:
My question wasn't about how to write a GIL image to a file, it was about the most efficient way to serialize it to a boost archive. The class that owns the GIL image in my case also has other state and the entire class instance needs to be serializable. Obviously I can get the raw data and serialize that out, but when reading in from the archive wouldn't I have to read it in to a temporary buffer and then use that buffer to reconstruct the GIL image? I'd rather not perform extra copies of pixel data like that if I don't have to.
It's not save_array, it is make_array :-) http://www.boost.org/doc/libs/1_38_0/libs/serialization/doc/wrappers.html#ar... -- Sohail Somani http://uint32t.blogspot.com
participants (4)
-
Kenny Riddile
-
Ross Levine
-
Sohail Somani
-
Tom Brinkman