Skip to content
Permalink
Browse files

fix map units per pixel in HiDPI

  • Loading branch information
3nids committed Oct 23, 2018
1 parent 2d1b539 commit c868e62ef5e96bddd2f6e9a396d0f0e06d6ac7a9
@@ -68,8 +68,8 @@ void QgsMapRendererCustomPainterJob::start()
QPaintDevice *paintDevice = mPainter->device();
QString errMsg = QStringLiteral( "pre-set DPI not equal to painter's DPI (%1 vs %2)" )
.arg( paintDevice->logicalDpiX() )
.arg( mSettings.outputDpi() );
Q_ASSERT_X( qgsDoubleNear( paintDevice->logicalDpiX(), mSettings.outputDpi() ),
.arg( mSettings.outputDpi() * mSettings.devicePixelRatio() );
Q_ASSERT_X( qgsDoubleNear( paintDevice->logicalDpiX(), mSettings.outputDpi() * mSettings.devicePixelRatio() ),
"Job::startRender()", errMsg.toLatin1().data() );
#endif

@@ -27,8 +27,8 @@ QgsMapRendererSequentialJob::QgsMapRendererSequentialJob( const QgsMapSettings &

mImage = QImage( mSettings.deviceOutputSize(), mSettings.outputImageFormat() );
mImage.setDevicePixelRatio( mSettings.devicePixelRatio() );
mImage.setDotsPerMeterX( 1000 * settings.outputDpi() / 25.4 );
mImage.setDotsPerMeterY( 1000 * settings.outputDpi() / 25.4 );
mImage.setDotsPerMeterX( mSettings.devicePixelRatio() * 1000 * settings.outputDpi() / 25.4 );
mImage.setDotsPerMeterY( mSettings.devicePixelRatio() * 1000 * settings.outputDpi() / 25.4 );
mImage.fill( Qt::transparent );
}

@@ -146,8 +146,8 @@ void QgsMapSettings::updateDerived()
}
}

double myHeight = mSize.height() * mDevicePixelRatio;
double myWidth = mSize.width() * mDevicePixelRatio;
double myHeight = mSize.height();
double myWidth = mSize.width();

if ( !myWidth || !myHeight )
{
@@ -180,7 +180,7 @@ void QgsMapSettings::updateDerived()
mVisibleExtent.set( dxmin, dymin, dxmax, dymax );

// update the scale
mScaleCalculator.setDpi( mDpi );
mScaleCalculator.setDpi( mDpi * mDevicePixelRatio );
mScale = mScaleCalculator.calculate( mVisibleExtent, mSize.width() );

mMapToPixel.setParameters( mapUnitsPerPixel(),
@@ -238,6 +238,7 @@ float QgsMapSettings::devicePixelRatio() const
void QgsMapSettings::setDevicePixelRatio( float dpr )
{
mDevicePixelRatio = dpr;
updateDerived();
}

QSize QgsMapSettings::deviceOutputSize() const

0 comments on commit c868e62

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