Skip to content
Permalink
Browse files

Merge pull request #670 from tqhien/master

Fix #7927 : Add a warning message if trying to print a composition
  • Loading branch information
mhugent committed Jun 22, 2013
2 parents f8d6e32 + bed65cb commit aa0a17b253f73ddaa913a09637a00175e3464a74
Showing with 12 additions and 0 deletions.
  1. +12 −0 src/app/composer/qgscomposer.cpp
@@ -940,6 +940,7 @@ void QgsComposer::on_mActionExportAsImage_triggered()
// Image size
int width = ( int )( mComposition->printResolution() * mComposition->paperWidth() / 25.4 );
int height = ( int )( mComposition-> printResolution() * mComposition->paperHeight() / 25.4 );
int dpi = ( int )( mComposition->printResolution() );

int memuse = width * height * 3 / 1000000; // pixmap + image
QgsDebugMsg( QString( "Image %1x%2" ).arg( width ).arg( height ) );
@@ -972,6 +973,17 @@ void QgsComposer::on_mActionExportAsImage_triggered()
for ( int i = 0; i < mComposition->numPages(); ++i )
{
QImage image = mComposition->printPageAsRaster( i );
if (image.isNull())
{
QMessageBox::warning( 0, tr( "Memory Allocation Error" ),
tr( "Trying to create image #%1 ( %2x%3 @ %4dpi )"
"may result in a memory overflow.\n"
"Please try a lower resolution or a smaller papersize" )
.arg( i+1 ).arg( width ).arg( height ).arg ( dpi ),
QMessageBox::Ok , QMessageBox::Ok );
mView->setPaintingEnabled( true );
return;
}
if ( i == 0 )
{
image.save( fileNExt.first, fileNExt.second.toLocal8Bit().constData() );

0 comments on commit aa0a17b

Please sign in to comment.
You can’t perform that action at this time.