MCPcopy Create free account
hub / github.com/Kitware/VTK / SaveAsPNG

Method SaveAsPNG

Rendering/Parallel/vtkSynchronizedRenderers.cxx:698–717  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

696
697//------------------------------------------------------------------------------
698void vtkSynchronizedRenderers::vtkRawImage::SaveAsPNG(const char* filename)
699{
700 if (!this->IsValid())
701 {
702 vtkGenericWarningMacro("Image is not valid. Cannot save PNG.");
703 return;
704 }
705
706 vtkNew<vtkImageData> img;
707 img->SetDimensions(this->Size[0], this->Size[1], 1);
708 img->AllocateScalars(VTK_UNSIGNED_CHAR, this->Data->GetNumberOfComponents());
709 auto scalars = vtkUnsignedCharArray::FastDownCast(img->GetPointData()->GetScalars());
710 std::copy_n(this->GetRawPtr()->GetPointer(0),
711 this->Size[0] * this->Size[1] * this->Data->GetNumberOfComponents(), scalars->GetPointer(0));
712
713 vtkNew<vtkPNGWriter> writer;
714 writer->SetFileName(filename);
715 writer->SetInputData(img);
716 writer->Write();
717}
718
719//------------------------------------------------------------------------------
720bool vtkSynchronizedRenderers::vtkRawImage::PushToViewport(vtkRenderer* ren, bool blend)

Callers

nothing calls this directly

Calls 11

FastDownCastFunction · 0.50
IsValidMethod · 0.45
SetDimensionsMethod · 0.45
AllocateScalarsMethod · 0.45
GetNumberOfComponentsMethod · 0.45
GetScalarsMethod · 0.45
GetPointDataMethod · 0.45
GetPointerMethod · 0.45
SetFileNameMethod · 0.45
SetInputDataMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected