vtkPNGWriter to stream

Hi dear friends,

I want to make a screenshot of a VTK Renderer into a PNG stream.
Way to go is obviously

vtkNew<vtkRenderLargeImage> renderLarge;

vtkNew<vtkPNGWriter> writer;
auto png = writer->GetResult();

but I don’t know how to translate the resulting “vtkUnsignedCharArray” into a contiguous “unsigned char*” to pass back to the caller …

Any advice ?
Thanks !

Something like this …

auto data = new unsigned char[png->GetSize()];
for (int i=0; i<data->Length; i++) data[i] = png->GetValue(i);

Nothing more efficient involving direct memory data copy ?

You can get access to the pointer to the actual data using:

which returns a unsigned char* to the element 0.