[vtkusers] save screenshot as png image
Wang Q
wangq1979 at outlook.com
Sun May 8 12:03:34 EDT 2016
Hi guys,
I have found a simple yet executable example. In case anyone also wants it, here is the link: https://gist.github.com/certik/5687727
________________________________
From: Wang Q <wangq1979 at outlook.com>
Sent: 06 May 2016 21:15
To: VTK Users
Subject: save screenshot as png image
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/20160508/de6cc393/attachment.html>
More information about the vtkusers
mailing list