How to put a pixel array into a vtkImageData?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to put a pixel array into a vtkImageData?

Jean-Do Barnichon
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


_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers