[vtkusers] Bug in vtkOpenGLImageActor ?

Jan Ehrhardt j.ehrhardt at uke.uni-hamburg.de
Wed Aug 24 09:17:08 EDT 2005


Hi,

I found a problem diplaying images with unconventional sizes using VTK 4.4.
If you re-render an image of size 181x217, it is displayed distorted.
I think the bug depends on the use of glTexSubImage2D in
vtkOpenGLImageActor::Load(). The following example programm
shows the same behaviour on linux and windows (but both machines
have nvidia cards).
How can I fix the problem?

Regards and greetings from germany,

Jan Ehrhardt

// use the example image form the ITK Toolkit
#define EXAMPLE_DATA 
"/passat/Software/ITK/InsightToolkit-2.0.1/Examples/Data/BrainProtonDensity3Slices.raw" 


int main( int argc, char **argv )
{
 double origin[3]={0,0,0};
 int extent[6]={0, 180, 0, 216, 0, 2};

 vtkImageReader *m_reader = vtkImageReader::New();
 m_reader->SetDataByteOrderToLittleEndian();
 m_reader->SetDataScalarTypeToUnsignedChar();
 m_reader->SetFileDimensionality(3);
 m_reader->SetDataExtent(extent);
 m_reader->SetDataOrigin(origin);
 m_reader->SetFileName(EXAMPLE_DATA);
 m_reader->SetNumberOfScalarComponents(1);
 m_reader->SetHeaderSize(0);
 m_reader->UpdateWholeExtent();

 vtkImageActor *m_Actor = vtkImageActor::New();
 m_Actor->SetInput(m_reader->GetOutput());
 m_Actor->SetDisplayExtent(extent[0],extent[1],extent[2], extent[3],1,1);

 vtkRenderer *m_Renderer = vtkRenderer::New();

 vtkRenderWindow *m_RenWin = vtkRenderWindow::New();
 m_RenWin->AddRenderer(m_Renderer);

 vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
 iren->SetRenderWindow(m_RenWin);

 vtkInteractorStyleImage *interactor = vtkInteractorStyleImage::New();
 iren->SetInteractorStyle(interactor);


 // Add the actors to the renderer, set the background and size
 m_Renderer->AddActor(m_Actor);
 m_Renderer->SetBackground(0.1, 0.2, 0.4);
 m_RenWin->SetSize(400, 400);

 m_RenWin->Render();

 // uncomment to see the distortion
 m_reader->Modified();

 m_RenWin->Render();

 // interact with data
 iren->Initialize();
 iren->Start();

 return 0;
}



More information about the vtkusers mailing list