[vtkusers] How to put a pixel array into a vtkImageData?
Jean-Dominique Barnichon
jeando.barnichon at free.fr
Fri Jan 20 16:14:44 EST 2006
Dear vtk'ers,
I'm doing 2D texture mapping.
In some cases, i read the image from a file using and the following code
snippet works fine:
...
// read image from file
vtkBMPReader* m_bmpReader = vtkBMPReader::New();
m_bmpReader->SetFileName("image.bmp");
// get vtkImageData from image
vtkImageData* m_TextureImage = vtkImageData::New();
m_TextureImage = m_bmpReader->GetOutput();
// then set vtkImageData to vtkTexture
vtkTexture* m_Texture = vtkTexture::New();
m_Texture->SetInput(m_TextureImage);
...
In some other cases, the image that i need to use as a texture is not
read from a file, but is directly a pixel array.
Obviously, i could write this pixel array to a bitmap file, and then
read it back from vtk using the above code, but i would much prefer to
avoid that for performance reasons.
What i really want is to put this pixel array into a vtkImageData
object, but so far i didn't succeed.
Any idea??
Thanks
J-D
More information about the vtkusers
mailing list