Skip to content

Commit 4f05da4

Browse files
agiudiceandreanyalldawson
authored andcommittedApr 13, 2018
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.
1 parent 91384a0 commit 4f05da4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎src/core/composer/qgscomposition.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -3058,8 +3058,8 @@ QImage QgsComposition::printPageAsRaster( int page, QSize imageSize, int dpi )
30583058
{
30593059
//output size in pixels specified, calculate resolution using average of
30603060
//derived x/y dpi
3061-
resolution = ( imageSize.width() / mPageWidth
3062-
+ imageSize.height() / mPageHeight ) / 2.0 * 25.4;
3061+
resolution = qRound(( imageSize.width() / mPageWidth
3062+
+ imageSize.height() / mPageHeight ) / 2.0 * 25.4 );
30633063
}
30643064
else if ( dpi > 0 )
30653065
{
@@ -3092,8 +3092,8 @@ QImage QgsComposition::renderRectAsRaster( const QRectF& rect, QSize imageSize,
30923092
{
30933093
//output size in pixels specified, calculate resolution using average of
30943094
//derived x/y dpi
3095-
resolution = ( imageSize.width() / rect.width()
3096-
+ imageSize.height() / rect.height() ) / 2.0 * 25.4;
3095+
resolution = qRound(( imageSize.width() / rect.width()
3096+
+ imageSize.height() / rect.height() ) / 2.0 * 25.4 );
30973097
}
30983098
else if ( dpi > 0 )
30993099
{

0 commit comments

Comments
 (0)