------------------------------------------------------------------------------
| 696 | |
| 697 | //------------------------------------------------------------------------------ |
| 698 | void 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 | //------------------------------------------------------------------------------ |
| 720 | bool vtkSynchronizedRenderers::vtkRawImage::PushToViewport(vtkRenderer* ren, bool blend) |
nothing calls this directly
no test coverage detected