@@ -1972,6 +1972,12 @@ void QgsComposer::exportCompositionAsImage( QgsComposer::OutputMode mode )
1972
1972
1973
1973
mView ->setPaintingEnabled ( false );
1974
1974
1975
+ int worldFilePageNo = -1 ;
1976
+ if ( mComposition ->generateWorldFile () && mComposition ->worldFileMap () )
1977
+ {
1978
+ worldFilePageNo = mComposition ->worldFileMap ()->page () - 1 ;
1979
+ }
1980
+
1975
1981
for ( int i = 0 ; i < mComposition ->numPages (); ++i )
1976
1982
{
1977
1983
if ( !mComposition ->shouldExportPage ( i + 1 ) )
@@ -1991,16 +1997,19 @@ void QgsComposer::exportCompositionAsImage( QgsComposer::OutputMode mode )
1991
1997
return ;
1992
1998
}
1993
1999
bool saveOk;
2000
+ QString outputFilePath;
1994
2001
if ( i == 0 )
1995
2002
{
1996
- saveOk = image. save ( fileNExt.first , fileNExt. second . toLocal8Bit (). constData () ) ;
2003
+ outputFilePath = fileNExt.first ;
1997
2004
}
1998
2005
else
1999
2006
{
2000
2007
QFileInfo fi ( fileNExt.first );
2001
- QString outputFilePath = fi.absolutePath () + " /" + fi.baseName () + " _" + QString::number ( i + 1 ) + " ." + fi.suffix ();
2002
- saveOk = image.save ( outputFilePath, fileNExt.second .toLocal8Bit ().constData () );
2008
+ outputFilePath = fi.absolutePath () + " /" + fi.baseName () + " _" + QString::number ( i + 1 ) + " ." + fi.suffix ();
2003
2009
}
2010
+
2011
+ saveOk = image.save ( outputFilePath, fileNExt.second .toLocal8Bit ().constData () );
2012
+
2004
2013
if ( !saveOk )
2005
2014
{
2006
2015
QMessageBox::warning ( this , tr ( " Image export error" ),
@@ -2010,21 +2019,20 @@ void QgsComposer::exportCompositionAsImage( QgsComposer::OutputMode mode )
2010
2019
mView ->setPaintingEnabled ( true );
2011
2020
return ;
2012
2021
}
2013
- }
2014
2022
2015
- //
2016
- // Write the world file if asked to
2017
- if ( mComposition ->generateWorldFile () )
2018
- {
2019
- double a, b, c, d, e, f;
2020
- mComposition ->computeWorldFileParameters ( a, b, c, d, e, f );
2023
+ if ( i == worldFilePageNo )
2024
+ {
2025
+ // should generate world file for this page
2026
+ double a, b, c, d, e, f;
2027
+ mComposition ->computeWorldFileParameters ( a, b, c, d, e, f );
2021
2028
2022
- QFileInfo fi ( fileNExt. first );
2023
- // build the world file name
2024
- QString worldFileName = fi.absolutePath () + " /" + fi.baseName () + " ."
2025
- + fi.suffix ()[0 ] + fi.suffix ()[fi.suffix ().size ()-1 ] + " w" ;
2029
+ QFileInfo fi ( outputFilePath );
2030
+ // build the world file name
2031
+ QString worldFileName = fi.absolutePath () + " /" + fi.baseName () + " ."
2032
+ + fi.suffix ()[0 ] + fi.suffix ()[fi.suffix ().size ()-1 ] + " w" ;
2026
2033
2027
- writeWorldFile ( worldFileName, a, b, c, d, e, f );
2034
+ writeWorldFile ( worldFileName, a, b, c, d, e, f );
2035
+ }
2028
2036
}
2029
2037
2030
2038
mView ->setPaintingEnabled ( true );
@@ -2150,6 +2158,12 @@ void QgsComposer::exportCompositionAsImage( QgsComposer::OutputMode mode )
2150
2158
2151
2159
QString filename = QDir ( dir ).filePath ( atlasMap->currentFilename () ) + fileExt;
2152
2160
2161
+ int worldFilePageNo = -1 ;
2162
+ if ( mComposition ->generateWorldFile () && mComposition ->worldFileMap () )
2163
+ {
2164
+ worldFilePageNo = mComposition ->worldFileMap ()->page () - 1 ;
2165
+ }
2166
+
2153
2167
for ( int i = 0 ; i < mComposition ->numPages (); ++i )
2154
2168
{
2155
2169
if ( !mComposition ->shouldExportPage ( i + 1 ) )
@@ -2177,21 +2191,20 @@ void QgsComposer::exportCompositionAsImage( QgsComposer::OutputMode mode )
2177
2191
QApplication::restoreOverrideCursor ();
2178
2192
return ;
2179
2193
}
2180
- }
2181
2194
2182
- //
2183
- // Write the world file if asked to
2184
- if ( mComposition ->generateWorldFile () )
2185
- {
2186
- double a, b, c, d, e, f;
2187
- mComposition ->computeWorldFileParameters ( a, b, c, d, e, f );
2195
+ if ( i == worldFilePageNo )
2196
+ {
2197
+ // should generate world file for this page
2198
+ double a, b, c, d, e, f;
2199
+ mComposition ->computeWorldFileParameters ( a, b, c, d, e, f );
2188
2200
2189
- QFileInfo fi ( filename );
2190
- // build the world file name
2191
- QString worldFileName = fi.absolutePath () + " /" + fi.baseName () + " ."
2192
- + fi.suffix ()[0 ] + fi.suffix ()[fi.suffix ().size ()-1 ] + " w" ;
2201
+ QFileInfo fi ( imageFilename );
2202
+ // build the world file name
2203
+ QString worldFileName = fi.absolutePath () + " /" + fi.baseName () + " ."
2204
+ + fi.suffix ()[0 ] + fi.suffix ()[fi.suffix ().size ()-1 ] + " w" ;
2193
2205
2194
- writeWorldFile ( worldFileName, a, b, c, d, e, f );
2206
+ writeWorldFile ( worldFileName, a, b, c, d, e, f );
2207
+ }
2195
2208
}
2196
2209
}
2197
2210
atlasMap->endRender ();
0 commit comments