Just Launched: You can now import projects and releases from Google Code onto SourceForge
We are excited to release new functionality to enable a 1-click import from Google Code onto the Allura platform on SourceForge. You can import tickets, wikis, source, releases, and more with a few simple steps. Read More
From: Christoph John <Christoph_J<ohn@gm...> - 2007-05-21 12:56:55
I am quite new to VXL and have a little question concerning how to play with VIL.
I have a vil_image_resource_sptr which I have created with vil_new_image_resource(). Furthermore I have a buffer of unsigned char.
I would like to fill my image_resource with the data in the buffer, with a simple memcpy, how is the right way to obtain a writable pointer to the image data of my resource buffer?
Thanks for your help.
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kanns mit allen: http://www.gmx.net/de/go/multimessenger
From: Ian Scott <ian.scott@st...> - 2007-05-21 13:47:25
Christoph John wrote:
> Hello together, I am quite new to VXL and have a little question
> concerning how to play with VIL. I have a vil_image_resource_sptr
> which I have created with vil_new_image_resource(). Furthermore I
> have a buffer of unsigned char. I would like to fill my
> image_resource with the data in the buffer, with a simple memcpy, how
> is the right way to obtain a writable pointer to the image data of my
> resource buffer?
> Thanks for your help.
> Cheers Christoph
An image resource is not meant to be memcpy'ed into. In general it
cannot work, since an image resource may represent an image on disk, or
the input of a pipeline of processing.
The best thing to do is to wrap the memory buffer in a vil_image_view
From the documentation:
> vil_image_view ::vil_image_view (const T *top_left, unsigned ni,
> unsigned nj, unsigned nplanes, vcl_ptrdiff_t i_step, vcl_ptrdiff_t
> j_step, vcl_ptrdiff_t plane_step)
> Set this view to look at someone else's memory data.
And then use the standard vil_image_resource put_view API to write it
in. If the resource is really an in-memory image, with the appropriate
pixel properties and arrangement, then it will copy the data using a
// a 128 by 128 grey image. Rasters start at top left.
// Create view around buffer
vil_image_view<vxl_byte> view(buffer, 128, 128, 1, 1, 128, 128*128);
// Copy view into resource. (assume resource is appropriate size, etc.)