Hi there, I tried to do screenshot with 'vtkWindowToImage` class, with the code below:
vtkSmartPointer<vtkWindowToImageFilter> shot = vtkSmartPointer<vtkWindowToImageFilter>::New();
shot->SetInput(m_pRenderWnd);
shot->SetInputBufferTypeToRGB(); //RGBA format
shot->SetScale(1); // here is the problem
shot->SetViewport(0, 0, 1, 1);
shot->Update();
const size_t buf = 256;
char buffer[buf];
size_t convertedChars = 0;
wcstombs_s(&convertedChars, buffer, buf, m_strpwzPath, _TRUNCATE);
const char* narrowString = buffer;
vtkNew<vtkPNGWriter> writer;
writer->SetFileName(narrowString);
writer->SetInputConnection(shot->GetOutputPort());
writer->Write();
When I tried to set setScale()
with 2, the saved image shows black crosshairs(could be transparent when I save as RGBA)
When I set back to 1 like setScale(1)
, the image is correct, but the resolution is bad.
Could you please give me some advice if I want to save the PNG picture with higher resolution but without that crosshairs? Great Thanks!