[gdal-dev] Possible interlaced 16-bit grayscale PNG read error
Ray at Daylon
rayg at daylongraphics.com
Sat Dec 28 01:42:12 PST 2024
In GDAL 1.8.0 on little-endian platforms like x64, the PNG driver will
not byteswap pixels from network order (big endian) to little-endian if
the PNG is interlaced (or at least if it's 16-bit grayscale interlaced).
Does anyone know if this was corrected in a future version?
In pngdataset.cpp, PNGDataset::LoadScanline() has this code:
if( bInterlaced )
return LoadInterlacedChunk( nLine );
The early return causes this downstream byteswapping section:
if( nBitDepth == 16 )
GDALSwapWords( row, 2, GetRasterXSize() * GetRasterCount(), 2 );
to be skipped.
LoadInterlacedChunk() as far as I can tell even in 3.9.2. doesn't
do any byteswapping.
Ray Gardener
More information about the gdal-dev
mailing list