You can copy your byte array into the VTK world and create a vktImageData
object to use it as InputConnection
.
vtkUnsignedCharArray myCharArray = vtkUnsignedCharArray.New();
GCHandle myPinnedArray = GCHandle.Alloc(myByteArray, GCHandleType.Pinned);
myCharArray.SetArray(myPinnedArray.AddrOfPinnedObject(), myData.Width * myData.Height * myData.Depth, 1);
vtkImageData myVtkImageData = vtkImageData.New();
myVtkImageData.GetPointData().SetScalars(myCharArray);
myVtkImageData.SetScalarTypeToUnsignedChar();
myVtkImageData.SetExtent(0, myData.Width - 1, 0, myData.Height - 1, myData.Depth -1);
myVtkImageData.Update();
The myData
is just a information about the image dimension of your byte array. You should also make sure that the GCHandle
and vtkImageData
object is not cleared by the GC
.
Depending on your data it's probably necessary to set Origin
and Spacing
.