Skip to content

Commit

Permalink
Backport of smizunos patch that fixes #1540
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/branches/Version-1_0@10593 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Apr 18, 2009
1 parent c2e13e7 commit f14d758
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -418,23 +418,25 @@ void QgsMapCanvas::saveAsImage( QString theFileName, QPixmap * theQPixmap, QStri
//create a world file to go with the image...
QgsRectangle myRect = mMapRenderer->extent();
QString myHeader;
// note: use 17 places of precision for all numbers output
//Pixel XDim
myHeader += QString::number( mapUnitsPerPixel() ) + "\r\n";
myHeader += QString::number( mapUnitsPerPixel(), 'g', 17 ) + "\r\n";
//Rotation on y axis - hard coded
myHeader += "0 \r\n";
//Rotation on x axis - hard coded
myHeader += "0 \r\n";
//Pixel YDim - almost always negative - see
//http://en.wikipedia.org/wiki/World_file#cite_note-2
myHeader += "-" + QString::number( mapUnitsPerPixel() ) + "\r\n";
//Origin X (top left corner)
myHeader += QString::number( myRect.xMinimum() ) + "\r\n";
//Origin Y (top left corner)
myHeader += QString::number( myRect.yMaximum() ) + "\r\n";
myHeader += "-" + QString::number( mapUnitsPerPixel(), 'g', 17 ) + "\r\n";
//Origin X (center of top left cell)
myHeader += QString::number( myRect.xMinimum() + ( mapUnitsPerPixel() / 2 ), 'g', 17 ) + "\r\n";
//Origin Y (center of top left cell)
myHeader += QString::number( myRect.yMaximum() - ( mapUnitsPerPixel() / 2 ), 'g', 17 ) + "\r\n";
QFileInfo myInfo = QFileInfo( theFileName );
QString myWorldFileName = myInfo.absolutePath() + QDir::separator() + myInfo.baseName() + "." + theFormat + "w";
// allow dotted names
QString myWorldFileName = myInfo.absolutePath() + QDir::separator() + myInfo.completeBaseName() + "." + theFormat + "w";
QFile myWorldFile( myWorldFileName );
if ( !myWorldFile.open( QIODevice::WriteOnly | QIODevice::Text ) )
if ( !myWorldFile.open( QIODevice::WriteOnly ) ) //don't use QIODevice::Text
{
return;
}
Expand Down

0 comments on commit f14d758

Please sign in to comment.