[vtkusers] Fit images in a QVTKWidget

Luis Roberto P. Paula luisrpp at gmail.com
Mon Oct 27 20:36:12 EDT 2008


Hi All,

Using the given example of an Image Viewer in Examples/GUI/Qt/ImageViewer,
what can I do to fit 2D images of any size to the size of a QVTKWidget?

Here is the code:

int main(int argc, char** argv)
{
  QApplication app(argc, argv);

  QVTKWidget widget;
  widget.resize(256,256);

#if QT_VERSION < 0x040000
  app.setMainWidget(&widget);
#endif

  vtkPNGReader* reader = vtkPNGReader::New();
  char* fname = vtkTestUtilities::ExpandDataFileName(argc, argv,
"Data/vtk.png");
  reader->SetFileName(fname);
  delete [] fname;

  vtkImageViewer* image_view = vtkImageViewer::New();
  image_view->SetInputConnection(reader->GetOutputPort());

  widget.SetRenderWindow(image_view->GetRenderWindow());
  image_view->SetupInteractor(widget.GetRenderWindow()->GetInteractor());

  image_view->SetColorLevel(138.5);
  image_view->SetColorWindow(233);

  widget.show();

  app.exec();


  image_view->Delete();
  reader->Delete();
}


Thanks,
Luis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081027/d06a25c3/attachment.htm>


More information about the vtkusers mailing list