|
76 | 76 | #include <QFileDialog>
|
77 | 77 | #include <QFileInfo>
|
78 | 78 | #include <QIcon>
|
| 79 | +#include <QImageWriter> |
79 | 80 | #include <QLabel>
|
80 | 81 | #include <QMatrix>
|
81 | 82 | #include <QMenuBar>
|
@@ -2069,7 +2070,7 @@ void QgsComposer::exportCompositionAsImage( QgsComposer::OutputMode mode )
|
2069 | 2070 | outputFilePath = fi.absolutePath() + '/' + fi.baseName() + '_' + QString::number( i + 1 ) + '.' + fi.suffix();
|
2070 | 2071 | }
|
2071 | 2072 |
|
2072 |
| - saveOk = image.save( outputFilePath, fileNExt.second.toLocal8Bit().constData() ); |
| 2073 | + saveOk = saveImage( image, outputFilePath, fileNExt.second ); |
2073 | 2074 |
|
2074 | 2075 | if ( !saveOk )
|
2075 | 2076 | {
|
@@ -2269,7 +2270,7 @@ void QgsComposer::exportCompositionAsImage( QgsComposer::OutputMode mode )
|
2269 | 2270 | imageFilename = fi.absolutePath() + '/' + fi.baseName() + '_' + QString::number( i + 1 ) + '.' + fi.suffix();
|
2270 | 2271 | }
|
2271 | 2272 |
|
2272 |
| - bool saveOk = image.save( imageFilename, format.toLocal8Bit().constData() ); |
| 2273 | + bool saveOk = saveImage( image, imageFilename, format ); |
2273 | 2274 | if ( !saveOk )
|
2274 | 2275 | {
|
2275 | 2276 | QMessageBox::warning( this, tr( "Atlas processing error" ),
|
@@ -2311,6 +2312,16 @@ void QgsComposer::exportCompositionAsImage( QgsComposer::OutputMode mode )
|
2311 | 2312 | }
|
2312 | 2313 | }
|
2313 | 2314 |
|
| 2315 | +bool QgsComposer::saveImage( const QImage &img, const QString &imageFilename, const QString &imageFormat ) |
| 2316 | +{ |
| 2317 | + QImageWriter w( imageFilename, imageFormat.toLocal8Bit().constData() ); |
| 2318 | + if ( imageFormat.compare( "tiff", Qt::CaseInsensitive ) == 0 || imageFormat.compare( "tif", Qt::CaseInsensitive ) == 0 ) |
| 2319 | + { |
| 2320 | + w.setCompression( 1 ); //use LZW compression |
| 2321 | + } |
| 2322 | + return w.write( img ); |
| 2323 | +} |
| 2324 | + |
2314 | 2325 | void QgsComposer::on_mActionExportAtlasAsSVG_triggered()
|
2315 | 2326 | {
|
2316 | 2327 | QgsComposition::AtlasMode previousMode = mComposition->atlasMode();
|
|
0 commit comments