Skip to content
Permalink
Browse files

Fixes a wrong dpi resolution in images exported from composer

In order to avoid wrong dpi resolution in images exported from composer we need to round the dpi resolution calculated "using average of derived x/y dpi" instead of truncate it to int.
  • Loading branch information
agiudiceandrea authored and nyalldawson committed Apr 13, 2018
1 parent 91384a0 commit 4f05da4a0de9e2c17b6e47bed36e7aca1c6d125d
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/core/composer/qgscomposition.cpp
@@ -3058,8 +3058,8 @@ QImage QgsComposition::printPageAsRaster( int page, QSize imageSize, int dpi )
{
//output size in pixels specified, calculate resolution using average of
//derived x/y dpi
resolution = ( imageSize.width() / mPageWidth
+ imageSize.height() / mPageHeight ) / 2.0 * 25.4;
resolution = qRound(( imageSize.width() / mPageWidth
+ imageSize.height() / mPageHeight ) / 2.0 * 25.4 );
}
else if ( dpi > 0 )
{
@@ -3092,8 +3092,8 @@ QImage QgsComposition::renderRectAsRaster( const QRectF& rect, QSize imageSize,
{
//output size in pixels specified, calculate resolution using average of
//derived x/y dpi
resolution = ( imageSize.width() / rect.width()
+ imageSize.height() / rect.height() ) / 2.0 * 25.4;
resolution = qRound(( imageSize.width() / rect.width()
+ imageSize.height() / rect.height() ) / 2.0 * 25.4 );
}
else if ( dpi > 0 )
{

0 comments on commit 4f05da4

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