diff --git a/src/core/utils/featureutils.cpp b/src/core/utils/featureutils.cpp index 4396b691bd..223014cc71 100644 --- a/src/core/utils/featureutils.cpp +++ b/src/core/utils/featureutils.cpp @@ -63,14 +63,15 @@ QgsRectangle FeatureUtils::extent( QgsQuickMapSettings *mapSettings, QgsVectorLa geom.transform( transf ); QgsRectangle extent; - const double rightPercentage = rightEdge / mapSettings->outputSize().width(); - const double bottomPercentage = bottomEdge / mapSettings->outputSize().height(); + QSizeF outputSize = mapSettings->outputSize() / mapSettings->devicePixelRatio(); + const double rightPercentage = rightEdge / outputSize.width(); + const double bottomPercentage = bottomEdge / outputSize.height(); if ( geom.type() == Qgis::GeometryType::Point ) { extent = mapSettings->extent(); QgsVector delta = QgsPointXY( geom.asPoint() ) - extent.center(); - const double deltaX = delta.x() + ( rightEdge > 0.0 ? mapSettings->mapUnitsPerPoint() * mapSettings->outputSize().width() * ( 0.5 - rightPercentage / 2.0 ) : 0.0 ); - const double deltaY = delta.y() - ( bottomEdge > 0.0 ? mapSettings->mapUnitsPerPoint() * mapSettings->outputSize().height() * ( 0.5 - ( 1.0 - bottomPercentage ) / 2.0 ) : 0.0 ); + const double deltaX = delta.x() + ( rightEdge > 0.0 ? mapSettings->mapUnitsPerPoint() * outputSize.width() * ( 0.5 - rightPercentage / 2.0 ) : 0.0 ); + const double deltaY = delta.y() - ( bottomEdge > 0.0 ? mapSettings->mapUnitsPerPoint() * outputSize.height() * ( 0.5 - ( 1.0 - bottomPercentage ) / 2.0 ) : 0.0 ); extent.setXMinimum( extent.xMinimum() + deltaX ); extent.setXMaximum( extent.xMaximum() + deltaX ); extent.setYMinimum( extent.yMinimum() + deltaY );