From 16868463a1363a63fe89542ea7fa2a254838783f Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 23 Oct 2019 15:22:40 +0200 Subject: [PATCH] JPEG: fix further calls to RasterIO after reading full image at full resolution (fixes #1947) --- autotest/gdrivers/jpeg.py | 8 ++++++++ gdal/frmts/jpeg/jpgdataset.cpp | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/autotest/gdrivers/jpeg.py b/autotest/gdrivers/jpeg.py index dd0d516b0266..dcfb53919836 100755 --- a/autotest/gdrivers/jpeg.py +++ b/autotest/gdrivers/jpeg.py @@ -796,8 +796,15 @@ def test_jpeg_23(): assert cs == got_cs # Pixel interleaved + ds = gdal.Open('data/albania.jpg') data = ds.ReadRaster(0, 0, ds.RasterXSize, ds.RasterYSize, buf_pixel_space=3, buf_band_space=1) + y = int(ds.RasterYSize/2) + data_bottom = ds.ReadRaster(0, y, ds.RasterXSize, ds.RasterYSize - y, + buf_pixel_space=3, buf_band_space=1) + data_top = ds.ReadRaster(0, 0, ds.RasterXSize, y, + buf_pixel_space=3, buf_band_space=1) + assert data == data_top + data_bottom tmp_ds = gdal.GetDriverByName('Mem').Create( '', ds.RasterXSize, ds.RasterYSize, 3) tmp_ds.WriteRaster(0, 0, ds.RasterXSize, ds.RasterYSize, data, @@ -806,6 +813,7 @@ def test_jpeg_23(): assert cs == got_cs # Pixel interleaved with padding + ds = gdal.Open('data/albania.jpg') data = ds.ReadRaster(0, 0, ds.RasterXSize, ds.RasterYSize, buf_pixel_space=4, buf_band_space=1) tmp_ds = gdal.GetDriverByName('Mem').Create( diff --git a/gdal/frmts/jpeg/jpgdataset.cpp b/gdal/frmts/jpeg/jpgdataset.cpp index 6ecc2b4e6512..422794f5648f 100644 --- a/gdal/frmts/jpeg/jpgdataset.cpp +++ b/gdal/frmts/jpeg/jpgdataset.cpp @@ -1869,7 +1869,7 @@ CPLErr JPGDatasetCommon::IRasterIO( GDALRWFlag eRWFlag, } } } - nLoadedScanline = -1; + nLoadedScanline = nRasterYSize; } else {