File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -940,6 +940,7 @@ void QgsComposer::on_mActionExportAsImage_triggered()
940
940
// Image size
941
941
int width = ( int )( mComposition ->printResolution () * mComposition ->paperWidth () / 25.4 );
942
942
int height = ( int )( mComposition -> printResolution () * mComposition ->paperHeight () / 25.4 );
943
+ int dpi = ( int )( mComposition ->printResolution () );
943
944
944
945
int memuse = width * height * 3 / 1000000 ; // pixmap + image
945
946
QgsDebugMsg ( QString ( " Image %1x%2" ).arg ( width ).arg ( height ) );
@@ -972,6 +973,17 @@ void QgsComposer::on_mActionExportAsImage_triggered()
972
973
for ( int i = 0 ; i < mComposition ->numPages (); ++i )
973
974
{
974
975
QImage image = mComposition ->printPageAsRaster ( i );
976
+ if (image.isNull ())
977
+ {
978
+ QMessageBox::warning ( 0 , tr ( " Memory Allocation Error" ),
979
+ tr ( " Trying to create image #%1 ( %2x%3 @ %4dpi )"
980
+ " may result in a memory overflow.\n "
981
+ " Please try a lower resolution or a smaller papersize" )
982
+ .arg ( i+1 ).arg ( width ).arg ( height ).arg ( dpi ),
983
+ QMessageBox::Ok , QMessageBox::Ok );
984
+ mView ->setPaintingEnabled ( true );
985
+ return ;
986
+ }
975
987
if ( i == 0 )
976
988
{
977
989
image.save ( fileNExt.first , fileNExt.second .toLocal8Bit ().constData () );
You can’t perform that action at this time.
0 commit comments