[vtkusers] Exporting a PNG image brings up a new window.

Jenya Burstein taijinian at gmail.com
Tue Aug 23 17:57:42 EDT 2011


Hello,

I am having a problem of adding a PNG export capability to an application.
Below is the functions that I use to export a PNG image.
The problem is that when running the applicaton remotly over Exceed X server
from Linux, a new window is displayed during vtkPNGWriter's Write() method.
That doesn't happen on Windows.

Is there a way to prevent that? Obviously, that is a very undesirable
side-effect - the window is as large as the requested image size and it
stays for the duration of the image export. It then disappears.

Any advice is greatly appreciated,
Jenya Burstein.

    void exportVTKPlotImage(vtkRenderWindow& renderWindow) const
    {
        vtkSmartPointer<vtkRenderWindow> exportingRenderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
        exportingRenderWindow->OffScreenRenderingOn();
        exportingRenderWindow->SetSize(1024, 768);
        vtkSmartPointer<vtkRenderer> renderer =
renderWindow.GetRenderers()->GetFirstRenderer();
        exportingRenderWindow->AddRenderer(renderer);
        vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter
= vtkSmartPointer<vtkWindowToImageFilter>::New();
        windowToImageFilter->SetInput(exportingRenderWindow);
        vtkSmartPointer<vtkPNGWriter> pngWriter =
vtkSmartPointer<vtkPNGWriter>::New();
        pngWriter->SetInputConnection(windowToImageFilter->GetOutputPort());
        pngWriter->SetFileName(file->absolutePath().c_str());
        pngWriter->Write();
        exportingRenderWindow->RemoveRenderer(renderer);
        renderer->SetRenderWindow(&renderWindow);
    }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110823/f8dea9a4/attachment.htm>


More information about the vtkusers mailing list