[vtkusers] How does one enforce recognition of little endian datain VTK?

vidyadhar vidyadhar at lucidindia.net
Fri Apr 29 23:25:14 EDT 2005


Hi,
You have not mentioned which reader you are using. Look at its inheritance
diagram. If it is derived from vtkImageReader2 then this class has a method
SwapBytesOn which may help you.
HTH
Vidyadhar
----- Original Message -----
From: "Sanatan Sahgal" <sanatan_sahgal at hotmail.com>
To: <vtkusers at vtk.org>
Sent: Friday, April 29, 2005 12:36 PM
Subject: [vtkusers] How does one enforce recognition of little endian datain
VTK?


> Hello,
>
> I am using VTK on an Intel platform running Windows XP professional. I
have
> a 2 bytes per pixel grayscale image which I wish to display on the screen
> using VTK.
>
> My image raw data is in little endian format and when I feed it to VTK I
see
> garbage on the screen because VTK seems to expect it in big endian format.
> If I swap the bytes and then feed it to VTK the image shows up correctly
on
> my screen.
>
> I don't want this extra overhead of swapping the bytes. I want VTK to
> recognize the raw little endian data just as it is. Is there any way to
tell
> VTK that my data is in little endian format and it should read it as such?
>
> I am using the vtkImageData class. I feed data to the imageData instance
as
> follows:
> imageData->GetPointData()->SetScalars(pixelArrayVtk);
>
> The pixelArrayVtk instance is of type vtkDataArray and it is setup as
> follows:
> pixelArrayVtk = CreateVtkDataArray(); //Creates instance of specific
> VtkDataArray type. Example: vtkShortArray::New()
> pixelArrayVtk->SetVoidArray(imageRawData, totalSamples, 1);
>
> The imageRawData parameter is a pointer to the memory location which
> contains the raw image data in little endian format.
>
> Any help with this issue is appreciated.
>
> thanks,
> Sanatan
>
>
>
>




More information about the vtkusers mailing list