Skip to content
Permalink
Browse files

Applied patch from smizuno that fixes bug #1540

git-svn-id: http://svn.osgeo.org/qgis/trunk@10592 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Apr 18, 2009
1 parent 99b6b67 commit 54306fb0af8d07c3e9031f8e5e3d44a6ef205aa1
Showing with 10 additions and 8 deletions.
  1. +10 −8 src/gui/qgsmapcanvas.cpp
@@ -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;
}

0 comments on commit 54306fb

Please sign in to comment.
You can’t perform that action at this time.