Skip to content

Commit

Permalink
Applied patch from smizuno that fixes bug #1540
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10592 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Apr 18, 2009
1 parent 197240b commit cbf5ee4
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... //create a world file to go with the image...
QgsRectangle myRect = mMapRenderer->extent(); QgsRectangle myRect = mMapRenderer->extent();
QString myHeader; QString myHeader;
// note: use 17 places of precision for all numbers output
//Pixel XDim //Pixel XDim
myHeader += QString::number( mapUnitsPerPixel() ) + "\r\n"; myHeader += QString::number( mapUnitsPerPixel(), 'g', 17 ) + "\r\n";
//Rotation on y axis - hard coded //Rotation on y axis - hard coded
myHeader += "0 \r\n"; myHeader += "0 \r\n";
//Rotation on x axis - hard coded //Rotation on x axis - hard coded
myHeader += "0 \r\n"; myHeader += "0 \r\n";
//Pixel YDim - almost always negative - see //Pixel YDim - almost always negative - see
//http://en.wikipedia.org/wiki/World_file#cite_note-2 //http://en.wikipedia.org/wiki/World_file#cite_note-2
myHeader += "-" + QString::number( mapUnitsPerPixel() ) + "\r\n"; myHeader += "-" + QString::number( mapUnitsPerPixel(), 'g', 17 ) + "\r\n";
//Origin X (top left corner) //Origin X (center of top left cell)
myHeader += QString::number( myRect.xMinimum() ) + "\r\n"; myHeader += QString::number( myRect.xMinimum() + ( mapUnitsPerPixel() / 2 ), 'g', 17 ) + "\r\n";
//Origin Y (top left corner) //Origin Y (center of top left cell)
myHeader += QString::number( myRect.yMaximum() ) + "\r\n"; myHeader += QString::number( myRect.yMaximum() - ( mapUnitsPerPixel() / 2 ), 'g', 17 ) + "\r\n";
QFileInfo myInfo = QFileInfo( theFileName ); 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 ); QFile myWorldFile( myWorldFileName );
if ( !myWorldFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) if ( !myWorldFile.open( QIODevice::WriteOnly ) ) //don't use QIODevice::Text
{ {
return; return;
} }
Expand Down

0 comments on commit cbf5ee4

Please sign in to comment.