[vtkusers] using vtkJPEGReader with vtkImageViewer2

Prathamesh Kulkarni prathameshmkulkarni at gmail.com
Tue Jul 13 19:23:31 EDT 2010


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100713/07917c0e/attachment.htm>


More information about the vtkusers mailing list