[vtkusers] using vtkJPEGReader with vtkImageViewer2

Jothy jothybasu at gmail.com
Wed Jul 14 03:59:19 EDT 2010


To change the window name, you have to first call Render() and then set the
window name.

It's the default behaviour of the vtkInteractorStyleImage to change window
level/width on "mouse move" which is used by vtkImageViewer2. If you don't
want this behavoiur, either subclass the interactor style or simplly don't
set the interacator to just display the image.

Jothy

On Wed, Jul 14, 2010 at 12:23 AM, Prathamesh Kulkarni <
prathameshmkulkarni at gmail.com> wrote:

>
> Hello all,
>
> Following is my code in which I am trying to read a JPEG image and display
> it:
>
>     vtkSmartPointer<vtkJPEGReader> jpeg_reader =
> vtkSmartPointer<vtkJPEGReader>::New();
>
>     if(jpeg_reader->CanReadFile(file_path.c_str()))
>     {
>         jpeg_reader->SetFileName(file_path.c_str());
>         jpeg_reader->Update();
>
>         vtkSmartPointer<vtkRenderWindowInteractor> interactor =
> vtkSmartPointer<vtkRenderWindowInteractor>::New();
>
>         vtkSmartPointer<vtkImageViewer2> image_viewer =
> vtkSmartPointer<vtkImageViewer2>::New();
>         image_viewer->SetInput(jpeg_reader->GetOutput());
>         image_viewer->SetupInteractor(interactor);
>         image_viewer->GetRenderer()->ResetCamera();
>         image_viewer->GetRenderer()->SetBackground(1.0, 1.0, 1.0);
>         image_viewer->GetRenderWindow()->SetWindowName("My Window");
>
>         interactor->Initialize();
>         interactor->Start();
>    }
>
>
> The code displays the image but I am having the following issues:
>
> 1. I am not able to change the window name as attempted above.
>
> 2. When I hold the left mouse button and drag, I see the image color map
> changing. I could not understand how to turn this behavior off (if at all
> this it is not erroneous) by looking at the class references.
>
>
> Any help will be appreciated.
>
> Thanks,
> Prathamesh
>
> _______________________________________________
> 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/20100714/4f310546/attachment.htm>


More information about the vtkusers mailing list