@@ -1866,6 +1866,12 @@ void QgsComposer::exportCompositionAsImage( QgsComposer::OutputMode mode )
1866
1866
1867
1867
mView ->setPaintingEnabled ( false );
1868
1868
1869
+ int worldFilePageNo = -1 ;
1870
+ if ( mComposition ->generateWorldFile () && mComposition ->worldFileMap () )
1871
+ {
1872
+ worldFilePageNo = mComposition ->worldFileMap ()->page () - 1 ;
1873
+ }
1874
+
1869
1875
for ( int i = 0 ; i < mComposition ->numPages (); ++i )
1870
1876
{
1871
1877
if ( !mComposition ->shouldExportPage ( i + 1 ) )
@@ -1885,16 +1891,19 @@ void QgsComposer::exportCompositionAsImage( QgsComposer::OutputMode mode )
1885
1891
return ;
1886
1892
}
1887
1893
bool saveOk;
1894
+ QString outputFilePath;
1888
1895
if ( i == 0 )
1889
1896
{
1890
- saveOk = image. save ( fileNExt.first , fileNExt. second . toLocal8Bit (). constData () ) ;
1897
+ outputFilePath = fileNExt.first ;
1891
1898
}
1892
1899
else
1893
1900
{
1894
1901
QFileInfo fi ( fileNExt.first );
1895
- QString outputFilePath = fi.absolutePath () + " /" + fi.baseName () + " _" + QString::number ( i + 1 ) + " ." + fi.suffix ();
1896
- saveOk = image.save ( outputFilePath, fileNExt.second .toLocal8Bit ().constData () );
1902
+ outputFilePath = fi.absolutePath () + " /" + fi.baseName () + " _" + QString::number ( i + 1 ) + " ." + fi.suffix ();
1897
1903
}
1904
+
1905
+ saveOk = image.save ( outputFilePath, fileNExt.second .toLocal8Bit ().constData () );
1906
+
1898
1907
if ( !saveOk )
1899
1908
{
1900
1909
QMessageBox::warning ( this , tr ( " Image export error" ),
@@ -1904,21 +1913,20 @@ void QgsComposer::exportCompositionAsImage( QgsComposer::OutputMode mode )
1904
1913
mView ->setPaintingEnabled ( true );
1905
1914
return ;
1906
1915
}
1907
- }
1908
1916
1909
- //
1910
- // Write the world file if asked to
1911
- if ( mComposition ->generateWorldFile () )
1912
- {
1913
- double a, b, c, d, e, f;
1914
- mComposition ->computeWorldFileParameters ( a, b, c, d, e, f );
1917
+ if ( i == worldFilePageNo )
1918
+ {
1919
+ // should generate world file for this page
1920
+ double a, b, c, d, e, f;
1921
+ mComposition ->computeWorldFileParameters ( a, b, c, d, e, f );
1915
1922
1916
- QFileInfo fi ( fileNExt. first );
1917
- // build the world file name
1918
- QString worldFileName = fi.absolutePath () + " /" + fi.baseName () + " ."
1919
- + fi.suffix ()[0 ] + fi.suffix ()[fi.suffix ().size ()-1 ] + " w" ;
1923
+ QFileInfo fi ( outputFilePath );
1924
+ // build the world file name
1925
+ QString worldFileName = fi.absolutePath () + " /" + fi.baseName () + " ."
1926
+ + fi.suffix ()[0 ] + fi.suffix ()[fi.suffix ().size ()-1 ] + " w" ;
1920
1927
1921
- writeWorldFile ( worldFileName, a, b, c, d, e, f );
1928
+ writeWorldFile ( worldFileName, a, b, c, d, e, f );
1929
+ }
1922
1930
}
1923
1931
1924
1932
mView ->setPaintingEnabled ( true );
@@ -2044,6 +2052,12 @@ void QgsComposer::exportCompositionAsImage( QgsComposer::OutputMode mode )
2044
2052
2045
2053
QString filename = QDir ( dir ).filePath ( atlasMap->currentFilename () ) + fileExt;
2046
2054
2055
+ int worldFilePageNo = -1 ;
2056
+ if ( mComposition ->generateWorldFile () && mComposition ->worldFileMap () )
2057
+ {
2058
+ worldFilePageNo = mComposition ->worldFileMap ()->page () - 1 ;
2059
+ }
2060
+
2047
2061
for ( int i = 0 ; i < mComposition ->numPages (); ++i )
2048
2062
{
2049
2063
if ( !mComposition ->shouldExportPage ( i + 1 ) )
@@ -2071,21 +2085,20 @@ void QgsComposer::exportCompositionAsImage( QgsComposer::OutputMode mode )
2071
2085
QApplication::restoreOverrideCursor ();
2072
2086
return ;
2073
2087
}
2074
- }
2075
2088
2076
- //
2077
- // Write the world file if asked to
2078
- if ( mComposition ->generateWorldFile () )
2079
- {
2080
- double a, b, c, d, e, f;
2081
- mComposition ->computeWorldFileParameters ( a, b, c, d, e, f );
2089
+ if ( i == worldFilePageNo )
2090
+ {
2091
+ // should generate world file for this page
2092
+ double a, b, c, d, e, f;
2093
+ mComposition ->computeWorldFileParameters ( a, b, c, d, e, f );
2082
2094
2083
- QFileInfo fi ( filename );
2084
- // build the world file name
2085
- QString worldFileName = fi.absolutePath () + " /" + fi.baseName () + " ."
2086
- + fi.suffix ()[0 ] + fi.suffix ()[fi.suffix ().size ()-1 ] + " w" ;
2095
+ QFileInfo fi ( imageFilename );
2096
+ // build the world file name
2097
+ QString worldFileName = fi.absolutePath () + " /" + fi.baseName () + " ."
2098
+ + fi.suffix ()[0 ] + fi.suffix ()[fi.suffix ().size ()-1 ] + " w" ;
2087
2099
2088
- writeWorldFile ( worldFileName, a, b, c, d, e, f );
2100
+ writeWorldFile ( worldFileName, a, b, c, d, e, f );
2101
+ }
2089
2102
}
2090
2103
}
2091
2104
atlasMap->endRender ();
0 commit comments