fill vtkImageData with user data

Adrian Anner a.anner at medres.ch
Wed Nov 17 05:32:44 EST 1999


hello

I have the data from a Picture in an 2d-Array (dim 512,512). Now I want
write this data to vtkImageData.

I tried the following but it didn't work :

   vtkImageData *outData = vtkImageData::New();
      outData->SetWholeExtent (0, 511, 0, 511, 0, 0);
      outData->SetScalarType(VTK_UNSIGNED_SHORT);

unsigned short *ptr;

   for (int y = 0; y <512;y++)
   {
      for (int x = 0; x <512; x++)


          ptr = (unsigned short *)(outData->GetScalarPointer(x, y, 0));
          *ptr = (unsigned short)Array[x][y];
      }
   }

it crashs with the error :

GetScalarPointer:Pixel(1,0,0) not in memory. Current extend = (0,0,0,0,0,0)

I'm using a recent nightly release.

thanks,

Adrian



-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------




More information about the vtkusers mailing list