Skip to content

Commit

Permalink
-Applied patch supplied by rouault to allow building internal pyramid…
Browse files Browse the repository at this point in the history
…s jpeg compression if libtiff 4.0 or greater is available

-Closes ticket #1357

git-svn-id: http://svn.osgeo.org/qgis/trunk@11187 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
ersts committed Jul 28, 2009
1 parent 9cb3b3f commit 1c15572
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/app/qgsrasterlayerproperties.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1572,7 +1572,7 @@ void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked()
else if ( res == "ERROR_JPEG_COMPRESSION" ) else if ( res == "ERROR_JPEG_COMPRESSION" )
{ {
QMessageBox::warning( this, tr( "Building pyramids failed." ), QMessageBox::warning( this, tr( "Building pyramids failed." ),
tr( "Building internal pyramid overviews is not supported on raster layers with JPEG compression." ) ); tr( "Building internal pyramid overviews is not supported on raster layers with JPEG compression and your current libtiff library." ) );
} }
else if ( res == "ERROR_VIRTUAL" ) else if ( res == "ERROR_VIRTUAL" )
{ {
Expand Down
17 changes: 13 additions & 4 deletions src/core/raster/qgsrasterlayer.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1014,11 +1014,20 @@ QString QgsRasterLayer::buildPyramids( RasterPyramidList const & theRasterPyrami


if ( theTryInternalFlag ) if ( theTryInternalFlag )
{ {
QString myCompressionType = QString( GDALGetMetadataItem( mGdalDataset, "COMPRESSION", "IMAGE_STRUCTURE" ) ); // libtiff < 4.0 has a bug that prevents safe building of overviews on JPEG compressed files
if ( "JPEG" == myCompressionType ) // we detect libtiff < 4.0 by checking that BIGTIFF is not in the creation options of the GTiff driver
// see https://trac.osgeo.org/qgis/ticket/1357
const char* pszGTiffCreationOptions =
GDALGetMetadataItem( GDALGetDriverByName( "GTiff" ), GDAL_DMD_CREATIONOPTIONLIST, "" );
if ( strstr( pszGTiffCreationOptions, "BIGTIFF" ) == NULL )
{ {
return "ERROR_JPEG_COMPRESSION"; QString myCompressionType = QString( GDALGetMetadataItem( mGdalDataset, "COMPRESSION", "IMAGE_STRUCTURE" ) );
if ( "JPEG" == myCompressionType )
{
return "ERROR_JPEG_COMPRESSION";
}
} }

//close the gdal dataset and reopen it in read / write mode //close the gdal dataset and reopen it in read / write mode
GDALClose( mGdalDataset ); GDALClose( mGdalDataset );
mGdalBaseDataset = GDALOpen( QFile::encodeName( mDataSource ).constData(), GA_Update ); mGdalBaseDataset = GDALOpen( QFile::encodeName( mDataSource ).constData(), GA_Update );
Expand Down Expand Up @@ -1501,7 +1510,7 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext )


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


mDataProvider->setDpi(rendererContext.rasterScaleFactor() * 25.4 * rendererContext.scaleFactor()); mDataProvider->setDpi( rendererContext.rasterScaleFactor() * 25.4 * rendererContext.scaleFactor() );


QImage* image = QImage* image =
mDataProvider->draw( mDataProvider->draw(
Expand Down

0 comments on commit 1c15572

Please sign in to comment.