@@ -56,6 +56,7 @@ email : sherman at mrcc.com
56
56
#include " qgsmaprenderercustompainterjob.h"
57
57
#include " qgsmaprendererparalleljob.h"
58
58
#include " qgsmaprenderersequentialjob.h"
59
+ #include " qgsmapsettingsutils.h"
59
60
#include " qgsmessagelog.h"
60
61
#include " qgsmessageviewer.h"
61
62
#include " qgspallabeling.h"
@@ -723,24 +724,8 @@ void QgsMapCanvas::saveAsImage( const QString &fileName, QPixmap *theQPixmap, co
723
724
painter.end ();
724
725
image.save ( fileName, format.toLocal8Bit ().data () );
725
726
726
- // create a world file to go with the image...
727
- QgsRectangle myRect = mapSettings ().visibleExtent ();
728
- QString myHeader;
729
- // note: use 17 places of precision for all numbers output
730
- // Pixel XDim
731
- myHeader += qgsDoubleToString ( mapUnitsPerPixel () ) + " \r\n " ;
732
- // Rotation on y axis - hard coded
733
- myHeader += QLatin1String ( " 0 \r\n " );
734
- // Rotation on x axis - hard coded
735
- myHeader += QLatin1String ( " 0 \r\n " );
736
- // Pixel YDim - almost always negative - see
737
- // http://en.wikipedia.org/wiki/World_file#cite_note-2
738
- myHeader += ' -' + qgsDoubleToString ( mapUnitsPerPixel () ) + " \r\n " ;
739
- // Origin X (center of top left cell)
740
- myHeader += qgsDoubleToString ( myRect.xMinimum () + ( mapUnitsPerPixel () / 2 ) ) + " \r\n " ;
741
- // Origin Y (center of top left cell)
742
- myHeader += qgsDoubleToString ( myRect.yMaximum () - ( mapUnitsPerPixel () / 2 ) ) + " \r\n " ;
743
727
QFileInfo myInfo = QFileInfo ( fileName );
728
+
744
729
// build the world file name
745
730
QString outputSuffix = myInfo.suffix ();
746
731
QString myWorldFileName = myInfo.absolutePath () + ' /' + myInfo.baseName () + ' .'
@@ -751,7 +736,7 @@ void QgsMapCanvas::saveAsImage( const QString &fileName, QPixmap *theQPixmap, co
751
736
return ;
752
737
}
753
738
QTextStream myStream ( &myWorldFile );
754
- myStream << myHeader ;
739
+ myStream << QgsMapSettingsUtils::worldFileContent ( mapSettings () ) ;
755
740
} // saveAsImage
756
741
757
742
0 commit comments