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)