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

Method nextGrid

ThirdParty/libproj/vtklibproj/src/grids.cpp:843–1079  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

841// ---------------------------------------------------------------------------
842
843std::unique_ptr<GTiffGrid> GTiffDataset::nextGrid() {
844 if (!m_hasNextGrid)
845 return nullptr;
846 if (m_nextDirOffset) {
847 TIFFSetSubDirectory(m_hTIFF, m_nextDirOffset);
848 }
849
850 uint32_t width = 0;
851 uint32_t height = 0;
852 TIFFGetField(m_hTIFF, TIFFTAG_IMAGEWIDTH, &width);
853 TIFFGetField(m_hTIFF, TIFFTAG_IMAGELENGTH, &height);
854 if (width == 0 || height == 0 || width > INT_MAX || height > INT_MAX) {
855 pj_log(m_ctx, PJ_LOG_ERROR, _("Invalid image size"));
856 return nullptr;
857 }
858
859 uint16_t samplesPerPixel = 0;
860 if (!TIFFGetField(m_hTIFF, TIFFTAG_SAMPLESPERPIXEL, &samplesPerPixel)) {
861 pj_log(m_ctx, PJ_LOG_ERROR, _("Missing SamplesPerPixel tag"));
862 return nullptr;
863 }
864 if (samplesPerPixel == 0) {
865 pj_log(m_ctx, PJ_LOG_ERROR, _("Invalid SamplesPerPixel value"));
866 return nullptr;
867 }
868
869 uint16_t bitsPerSample = 0;
870 if (!TIFFGetField(m_hTIFF, TIFFTAG_BITSPERSAMPLE, &bitsPerSample)) {
871 pj_log(m_ctx, PJ_LOG_ERROR, _("Missing BitsPerSample tag"));
872 return nullptr;
873 }
874
875 uint16_t planarConfig = 0;
876 if (!TIFFGetField(m_hTIFF, TIFFTAG_PLANARCONFIG, &planarConfig)) {
877 pj_log(m_ctx, PJ_LOG_ERROR, _("Missing PlanarConfig tag"));
878 return nullptr;
879 }
880
881 uint16_t sampleFormat = 0;
882 if (!TIFFGetField(m_hTIFF, TIFFTAG_SAMPLEFORMAT, &sampleFormat)) {
883 pj_log(m_ctx, PJ_LOG_ERROR, _("Missing SampleFormat tag"));
884 return nullptr;
885 }
886
887 TIFFDataType dt;
888 if (sampleFormat == SAMPLEFORMAT_INT && bitsPerSample == 16)
889 dt = TIFFDataType::Int16;
890 else if (sampleFormat == SAMPLEFORMAT_UINT && bitsPerSample == 16)
891 dt = TIFFDataType::UInt16;
892 else if (sampleFormat == SAMPLEFORMAT_INT && bitsPerSample == 32)
893 dt = TIFFDataType::Int32;
894 else if (sampleFormat == SAMPLEFORMAT_UINT && bitsPerSample == 32)
895 dt = TIFFDataType::UInt32;
896 else if (sampleFormat == SAMPLEFORMAT_IEEEFP && bitsPerSample == 32)
897 dt = TIFFDataType::Float32;
898 else if (sampleFormat == SAMPLEFORMAT_IEEEFP && bitsPerSample == 64)
899 dt = TIFFDataType::Float64;
900 else {

Callers 1

openMethod · 0.80

Calls 12

TIFFSetSubDirectoryFunction · 0.85
TIFFGetFieldFunction · 0.85
pj_logFunction · 0.85
TIFFIsCODECConfiguredFunction · 0.85
TIFFIsTiledFunction · 0.85
TIFFTileSize64Function · 0.85
TIFFStripSize64Function · 0.85
TIFFReadDirectoryFunction · 0.85
TIFFCurrentDirOffsetFunction · 0.85
swapFunction · 0.50
c_strMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected