File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed
Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -472,3 +472,13 @@ def test_png_copy_mdd():
472472 ds = None
473473
474474 gdal .Unlink (filename )
475+
476+
477+ ###############################################################################
478+ # Read test of 16-bit interlaced
479+
480+
481+ def test_png_read_interlace_16_bit ():
482+
483+ ds = gdal .Open ("data/png/uint16_interlaced.png" )
484+ assert ds .GetRasterBand (1 ).Checksum () == 4672
Original file line number Diff line number Diff line change @@ -1405,6 +1405,21 @@ CPLErr PNGDataset::LoadInterlacedChunk(int iLine)
14051405
14061406 bool bRet = safe_png_read_image (hPNG, png_rows, sSetJmpContext );
14071407
1408+ // Do swap on LSB machines. 16-bit PNG data is stored in MSB format.
1409+ #ifdef CPL_LSB
1410+ if (bRet && nBitDepth == 16 )
1411+ {
1412+ for (int i = 0 ; i < GetRasterYSize (); i++)
1413+ {
1414+ if (i >= nBufferStartLine && i < nBufferStartLine + nBufferLines)
1415+ {
1416+ GDALSwapWords (png_rows[i], 2 ,
1417+ GetRasterXSize () * GetRasterCount (), 2 );
1418+ }
1419+ }
1420+ }
1421+ #endif
1422+
14081423 CPLFree (png_rows);
14091424 CPLFree (dummy_row);
14101425 if (!bRet)
You can’t perform that action at this time.
0 commit comments