> Well you can ask the vil_image_resource_sptr, what its pixel type is,
> and then do a switch on that.
Uh, I feared something like that. Although I already do something like
this to set the proper OpenGL data type and format (see your question
below), it would be convenient to have a method in VIL which does this
"switching" for you and provides a view that matches the ressource's format.
>>> 3: Raw image data only exists in a file format. If an image
>> has been loaded into memory by vil, then it exists as a (not
>> necessarily compact) array of pixels. If you want to coerce these
>> pixels into a suitable form, then do something like:
>>> vil_image_view<vxl_byte> my_view = vil_new_image_view_plane_i_j(
>>> view.ni(), view.nj(), view.nplanes()); vil_copy_reformat(view,
>>> my_view); my_view->top_left_ptr() now points to a compact
>>> vxl_byte array of my_view->size() pixels.
BTW: This code does not work for me. First, the compiler complained
about a missing dummy argument for "new_image_view_plane_i_j", but when
providing that dummy an assertion fails (vil_image_view.txx:75). Since
this methis is deprecated anyway, I tried to use the "image_view"
constructor instead. This seems to work, but the image still isn't
cout << view.is_contiguous() << endl; // prints "false"
cout << data.is_contiguous() << endl; // prints "false"
What am I doing wrong to force the data to be contiguous?
> My point was: There is no such thing as a "native format". Image
> loaders have to deal with issues such as byte swapping and bit
Okay, I see your point.
>> Therefore I read width, height, type and format of a slice using
>> the ni(), nj(), nplanes() and pixel_format() methods. What's
>> missing is a pointer to the tightly packed decoded image data in
>> its native format. As I see it, all your suggestions so far either
>> assume a certain im age format or explicitly convert to a certain
>> format. Isn't there a way to get a pointer to the whole image data
>> without assuming it to be in a certain format?
> If you don't know what format the data is in, then how will OpenGL
You got me (see above), I already use a switch :-) I simply hoped this
wouldn't be necessary to use with VIL.
Institute of ComputerGraphics
Technical University at Brunswick
Phone: +49 531 391-2113, Fax: -2103