From 9f74bbb27adeb9af508486f37269db2c60e56615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Fri, 24 Aug 2018 00:14:40 +0200 Subject: [PATCH] Some more code cleanup --- src/map/image.cpp | 8 ++++---- src/map/image.h | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/map/image.cpp b/src/map/image.cpp index aaf2f922..0365422f 100644 --- a/src/map/image.cpp +++ b/src/map/image.cpp @@ -3,13 +3,14 @@ #include "image.h" -Image::Image(const QString &fileName) : _img(fileName), _ratio(1.0) +Image::Image(const QString &fileName) : _img(fileName) { } void Image::draw(QPainter *painter, const QRectF &rect, Map::Flags flags) { - QRectF sr(rect.topLeft() * _ratio, rect.size() * _ratio); + qreal ratio = _img.devicePixelRatioF(); + QRectF sr(rect.topLeft() * ratio, rect.size() * ratio); if (flags & Map::OpenGL) { QImage img(_img.copy(sr.toRect())); @@ -21,7 +22,6 @@ void Image::draw(QPainter *painter, const QRectF &rect, Map::Flags flags) void Image::setDevicePixelRatio(qreal ratio) { #ifdef ENABLE_HIDPI - _ratio = ratio; - _img.setDevicePixelRatio(_ratio); + _img.setDevicePixelRatio(ratio); #endif // ENABLE_HIDPI } diff --git a/src/map/image.h b/src/map/image.h index 4edd96a7..720d1dfe 100644 --- a/src/map/image.h +++ b/src/map/image.h @@ -16,7 +16,6 @@ public: private: QImage _img; - qreal _ratio; }; #endif // IMAGE_H