@@ -1014,11 +1014,20 @@ QString QgsRasterLayer::buildPyramids( RasterPyramidList const & theRasterPyrami
1014
1014
1015
1015
if ( theTryInternalFlag )
1016
1016
{
1017
- QString myCompressionType = QString ( GDALGetMetadataItem ( mGdalDataset , " COMPRESSION" , " IMAGE_STRUCTURE" ) );
1018
- if ( " JPEG" == myCompressionType )
1017
+ // libtiff < 4.0 has a bug that prevents safe building of overviews on JPEG compressed files
1018
+ // we detect libtiff < 4.0 by checking that BIGTIFF is not in the creation options of the GTiff driver
1019
+ // see https://trac.osgeo.org/qgis/ticket/1357
1020
+ const char * pszGTiffCreationOptions =
1021
+ GDALGetMetadataItem ( GDALGetDriverByName ( " GTiff" ), GDAL_DMD_CREATIONOPTIONLIST, " " );
1022
+ if ( strstr ( pszGTiffCreationOptions, " BIGTIFF" ) == NULL )
1019
1023
{
1020
- return " ERROR_JPEG_COMPRESSION" ;
1024
+ QString myCompressionType = QString ( GDALGetMetadataItem ( mGdalDataset , " COMPRESSION" , " IMAGE_STRUCTURE" ) );
1025
+ if ( " JPEG" == myCompressionType )
1026
+ {
1027
+ return " ERROR_JPEG_COMPRESSION" ;
1028
+ }
1021
1029
}
1030
+
1022
1031
// close the gdal dataset and reopen it in read / write mode
1023
1032
GDALClose ( mGdalDataset );
1024
1033
mGdalBaseDataset = GDALOpen ( QFile::encodeName ( mDataSource ).constData (), GA_Update );
@@ -1501,7 +1510,7 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext )
1501
1510
1502
1511
emit statusChanged ( tr ( " Retrieving using %1" ).arg ( mProviderKey ) );
1503
1512
1504
- mDataProvider ->setDpi (rendererContext.rasterScaleFactor () * 25.4 * rendererContext.scaleFactor ());
1513
+ mDataProvider ->setDpi ( rendererContext.rasterScaleFactor () * 25.4 * rendererContext.scaleFactor () );
1505
1514
1506
1515
QImage* image =
1507
1516
mDataProvider ->draw (
0 commit comments