[vtkusers] save screenshot as png image

Wang Q wangq1979 at outlook.com
Fri May 6 16:15:59 EDT 2016


Hi guys,


I want to save screenshot as png image following the example. Unfortunately, the code went into windowToImageFilter->Update() method and never came back. Below is the snippet:


// Screenshot
    vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter =
        vtkSmartPointer<vtkWindowToImageFilter>::New();
    windowToImageFilter->SetInput(renderWindow);
    //windowToImageFilter->SetMagnification(3); //set the resolution of the output image (3 times the current resolution of vtk render window)
    //windowToImageFilter->SetInputBufferTypeToRGBA(); //also record the alpha (transparency) channel
    //windowToImageFilter->ReadFrontBufferOff(); // read from the back buffer
    windowToImageFilter->Update();

    vtkSmartPointer<vtkPNGWriter> writer =
        vtkSmartPointer<vtkPNGWriter>::New();
    writer->SetFileName("e:/screenshot2.png");
    writer->SetInputConnection(windowToImageFilter->GetOutputPort());
    writer->Write();

renderWindow->Render();
    timerLog->MarkEvent("finish rendering");
renderWindowInteractor->Start();


I am using win10, vtk6.3 on vc2013.


Any tips would be appreciated.


Cheers,


Chiang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160506/06516157/attachment.html>


More information about the vtkusers mailing list