Skip to content

Commit 81758a3

Browse files
author
ersts
committed
-Applied patch supplied by rouault to allow building internal pyramids jpeg compression if libtiff 4.0 or greater is available
-Closes ticket #1357 git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11187 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 5a0a8da commit 81758a3

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/app/qgsrasterlayerproperties.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,7 @@ void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked()
15721572
else if ( res == "ERROR_JPEG_COMPRESSION" )
15731573
{
15741574
QMessageBox::warning( this, tr( "Building pyramids failed." ),
1575-
tr( "Building internal pyramid overviews is not supported on raster layers with JPEG compression." ) );
1575+
tr( "Building internal pyramid overviews is not supported on raster layers with JPEG compression and your current libtiff library." ) );
15761576
}
15771577
else if ( res == "ERROR_VIRTUAL" )
15781578
{

src/core/raster/qgsrasterlayer.cpp

+13-4
Original file line numberDiff line numberDiff line change
@@ -1014,11 +1014,20 @@ QString QgsRasterLayer::buildPyramids( RasterPyramidList const & theRasterPyrami
10141014

10151015
if ( theTryInternalFlag )
10161016
{
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 )
10191023
{
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+
}
10211029
}
1030+
10221031
//close the gdal dataset and reopen it in read / write mode
10231032
GDALClose( mGdalDataset );
10241033
mGdalBaseDataset = GDALOpen( QFile::encodeName( mDataSource ).constData(), GA_Update );
@@ -1501,7 +1510,7 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext )
15011510

15021511
emit statusChanged( tr( "Retrieving using %1" ).arg( mProviderKey ) );
15031512

1504-
mDataProvider->setDpi(rendererContext.rasterScaleFactor() * 25.4 * rendererContext.scaleFactor());
1513+
mDataProvider->setDpi( rendererContext.rasterScaleFactor() * 25.4 * rendererContext.scaleFactor() );
15051514

15061515
QImage* image =
15071516
mDataProvider->draw(

0 commit comments

Comments
 (0)