[vtkusers] Transparency in screenshot

David Gobbi david.gobbi at gmail.com
Mon Jan 31 11:51:24 EST 2011


2011/1/31 Dženan Zukić <dzenanz at gmail.com>:
> Hi all,
> I have a problem with saving transparency from a screenshot into a file.
> unsigned char
> *pixDebug=vis->GetRenderWindow()->GetRGBACharPixelData(0,0,512,512,1);
> //pixDebug contains alpha channel (determined by manual inspection of array
> in debugger)
> vtkWindowToImageFilter *windowGrabber=vtkWindowToImageFilter::New();
> windowGrabber->SetInput(vis->GetRenderWindow()); //vis is a QVTK component
> vtkPNGWriter *writer=vtkPNGWriter::New();
> writer->SetInput(windowGrabber->GetOutput());
> writer->SetFileName(filename.c_str());
> writer->Write(); //file does not have alpha channel
> Do you have any suggestions?

Try this: windowGrabber->SetInputBufferTypeToRGBA();

 - David



More information about the vtkusers mailing list