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

Method vtkPNGReaderUpdate2

IO/Image/vtkPNGReader.cxx:433–572  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

431//------------------------------------------------------------------------------
432template <class OT>
433void vtkPNGReader::vtkPNGReaderUpdate2(OT* outPtr, int* outExt, vtkIdType* outInc, long pixSize)
434{
435 vtkPNGReader::vtkInternals* impl = this->Internals;
436 unsigned int ui;
437 int i;
438 FILE* fp = nullptr;
439 MemoryBufferStream stream;
440
441 if (this->GetStream())
442 {
443 // Reset stream to the beginning
444 this->GetStream()->Seek(0, vtkResourceStream::SeekDirection::Begin);
445
446 // Read the header from MemoryBuffer
447 if (!impl->CheckBufferHeaderStream(this->GetStream()))
448 {
449 vtkErrorMacro("Invalid MemoryBuffer header: not a PNG file");
450 this->SetErrorCode(vtkErrorCode::UnrecognizedFileTypeError);
451 return;
452 }
453 }
454 else if (this->GetMemoryBuffer())
455 {
456 // VTK_DEPRECATED_IN_9_6_0
457 // Read the header from MemoryBuffer
458 const unsigned char* memBuffer = static_cast<const unsigned char*>(this->GetMemoryBuffer());
459 if (!impl->CheckBufferHeader(memBuffer, this->GetMemoryBufferLength()))
460 {
461 vtkErrorMacro("Invalid MemoryBuffer header: not a PNG file");
462 this->SetErrorCode(vtkErrorCode::FileFormatError);
463 return;
464 }
465 }
466 else
467 {
468 // Attempt to open the file and read the header
469 fp = vtksys::SystemTools::Fopen(this->InternalFileName, "rb");
470 if (!fp)
471 {
472 vtkErrorMacro("Unable to open file " << this->InternalFileName);
473 this->SetErrorCode(vtkErrorCode::CannotOpenFileError);
474 return;
475 }
476 if (!impl->CheckFileHeader(fp))
477 {
478 vtkErrorMacro("Invalid file header: not a PNG file");
479 fclose(fp);
480 this->SetErrorCode(vtkErrorCode::FileFormatError);
481 return;
482 }
483 }
484
485 png_structp png_ptr = nullptr;
486 png_infop info_ptr = nullptr;
487 png_infop end_info = nullptr;
488 if (!impl->CreateLibPngStructs(png_ptr, info_ptr, end_info))
489 {
490 if (fp)

Callers 1

vtkPNGReaderUpdateMethod · 0.95

Calls 15

png_read_infoFunction · 0.85
png_get_IHDRFunction · 0.85
png_set_palette_to_rgbFunction · 0.85
png_get_validFunction · 0.85
png_set_tRNS_to_alphaFunction · 0.85
png_set_swapFunction · 0.85
png_read_update_infoFunction · 0.85
png_get_rowbytesFunction · 0.85
png_read_imageFunction · 0.85
png_destroy_read_structFunction · 0.85

Tested by

no test coverage detected