From 73d64e29878ad49ac2b2039311abccafb5331a00 Mon Sep 17 00:00:00 2001 From: borgmanJeremy <46930769+borgmanJeremy@users.noreply.github.com> Date: Fri, 10 Dec 2021 11:43:21 -0600 Subject: [PATCH] fixed an issue with the invert tool on hidpi screens (#2153) --- src/tools/invert/inverttool.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/tools/invert/inverttool.cpp b/src/tools/invert/inverttool.cpp index 3597e4f2..60854ec6 100644 --- a/src/tools/invert/inverttool.cpp +++ b/src/tools/invert/inverttool.cpp @@ -49,14 +49,17 @@ CaptureTool* InvertTool::copy(QObject* parent) void InvertTool::process(QPainter& painter, const QPixmap& pixmap) { - QRect selection = boundingRect(); + QRect selection = boundingRect().intersected(pixmap.rect()); + auto pixelRatio = pixmap.devicePixelRatio(); + QRect selectionScaled = QRect(selection.topLeft() * pixelRatio, + selection.bottomRight() * pixelRatio); // Invert selection - QPixmap inv = pixmap.copy(selection); + QPixmap inv = pixmap.copy(selectionScaled); QImage img = inv.toImage(); img.invertPixels(); - painter.drawImage(selection.intersected(pixmap.rect()), img); + painter.drawImage(selection, img); } void InvertTool::drawSearchArea(QPainter& painter, const QPixmap& pixmap)