From 0503a83a864ff9b25cc30f65eb34602c3da94028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= <luisangelsm@gmail.com> Date: Sat, 1 Jun 2019 10:51:58 +0200 Subject: [PATCH 1/2] Use device pixel ratio when using intermediate images in lens --- YACReader/magnifying_glass.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/YACReader/magnifying_glass.cpp b/YACReader/magnifying_glass.cpp index e1b586ab..31e9d5c8 100644 --- a/YACReader/magnifying_glass.cpp +++ b/YACReader/magnifying_glass.cpp @@ -77,6 +77,7 @@ void MagnifyingGlass::updateImage(int x, int y) } if (outImage) { QImage img(zoomWidth, zoomHeight, QImage::Format_RGB32); + img.setDevicePixelRatio(devicePixelRatio()); img.fill(Configuration::getConfiguration().getBackgroundColor()); if (zw > 0 && zh > 0) { QPainter painter(&img); @@ -117,6 +118,7 @@ void MagnifyingGlass::updateImage(int x, int y) } if (outImage) { QImage img(zoomWidth, zoomHeight, QImage::Format_RGB32); + img.setDevicePixelRatio(devicePixelRatio()); img.fill(Configuration::getConfiguration().getBackgroundColor()); if (zw > 0 && zh > 0) { QPainter painter(&img); From 0ab94181cc3666c49ab1cabfbf4bc07a56055070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= <luisangelsm@gmail.com> Date: Sat, 1 Jun 2019 12:13:06 +0200 Subject: [PATCH 2/2] Use exiting variable instead of request the image several times --- YACReader/magnifying_glass.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/YACReader/magnifying_glass.cpp b/YACReader/magnifying_glass.cpp index 31e9d5c8..a7c9492b 100644 --- a/YACReader/magnifying_glass.cpp +++ b/YACReader/magnifying_glass.cpp @@ -81,11 +81,11 @@ void MagnifyingGlass::updateImage(int x, int y) img.fill(Configuration::getConfiguration().getBackgroundColor()); if (zw > 0 && zh > 0) { QPainter painter(&img); - painter.drawPixmap(xOffset, yOffset, p->pixmap()->copy(xp, yp, zw, zh)); + painter.drawPixmap(xOffset, yOffset, image->copy(xp, yp, zw, zh)); } setPixmap(QPixmap().fromImage(img)); } else - setPixmap(p->pixmap()->copy(xp, yp, zoomWidth, zoomHeight)); + setPixmap(image->copy(xp, yp, zoomWidth, zoomHeight)); } else { int xp = static_cast<int>(((x - p->widget()->pos().x()) * wFactor) - zoomWidth / 2); int yp = static_cast<int>((y + currentPos) * hFactor - zoomHeight / 2); @@ -122,11 +122,11 @@ void MagnifyingGlass::updateImage(int x, int y) img.fill(Configuration::getConfiguration().getBackgroundColor()); if (zw > 0 && zh > 0) { QPainter painter(&img); - painter.drawPixmap(xOffset, yOffset, p->pixmap()->copy(xp, yp, zw, zh)); + painter.drawPixmap(xOffset, yOffset, image->copy(xp, yp, zw, zh)); } setPixmap(QPixmap().fromImage(img)); } else - setPixmap(p->pixmap()->copy(xp, yp, zoomWidth, zoomHeight)); + setPixmap(image->copy(xp, yp, zoomWidth, zoomHeight)); } move(static_cast<int>(x - float(width()) / 2), static_cast<int>(y - float(height()) / 2)); }