[vtkusers] How to enlarge an image with vtkImageActor and vtkInteractorStyleImage

John Anaia john.anaia at gmail.com
Wed Feb 26 01:15:02 EST 2014


The following two lines did the trick. The order of two lines also matters!

  renderer->ResetCamera();
  renderer->GetActiveCamera()->Zoom(1.5);

John


On Mon, Feb 24, 2014 at 11:21 PM, Morten Wigen <morten.wigen at gmail.com>wrote:

> Hi John,
> I asked the same thing the other day without any response. If you figure
> it out, I would appreciate if you gave me a heads up!
>
> Morten
>
> > Den 25. feb. 2014 kl. 06:08 skrev John Anaia <john.anaia at gmail.com>:
> >
> > (Sorry for last email without a subject line)
> >
> > I want to display a PNG image thru vtkImageActor and
> vtkInteractorStyleImage on QVTKWidget. Everything works fine except the
> image appears too small. How do I make the image appears larger when I show
> it the first time without mouse interaction? I tried Dolly but no effect at
> all. Someone please recommend a camera function to enlarge the image? Here
> is my code
> >
> >   vtkSmartPointer<vtkPNGReader> reader = vtkSmartPointer<vtkPNGReader>:
> > :New();
> >
> >   QString path = QCoreApplication::applicationDirPath();
> >   path.append("/icons/logo.png");
> >   reader->SetFileName((path.toStdString()).c_str());
> >
> >   vtkSmartPointer<vtkImageActor> imgactor =
> vtkSmartPointer<vtkImageActor>::New();
> >   imgactor->SetInput(reader->GetOutput());
> >
> >   vtkSmartPointer<vtkInteractorStyleImage> isi =
> >     vtkSmartPointer<vtkInteractorStyleImage>::New();
> >
> gUI.qvtkWidget->GetRenderWindow()->GetInteractor()->SetInteractorStyle(isi);
> >
> >   // a renderer and render window
> >   vtkRenderer *ren1 = vtkRenderer::New();
> >   gUI.qvtkWidget->GetRenderWindow()->AddRenderer(ren1);
> >
> >   // add the actor to the scene
> >   ren1->AddViewProp(imgactor);
> >   ren1->SetBackground(1,1,1);     // Background color
> >
> >   ren1->GetActiveCamera()->Dolly(1.0);
> >
> >
> > Thank you!
> >
> > John
> > _______________________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> >
> > Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140225/a44fddff/attachment.html>


More information about the vtkusers mailing list