fixed an issue with the invert tool on hidpi screens (#2153)

This commit is contained in:
borgmanJeremy
2021-12-10 11:43:21 -06:00
committed by GitHub
parent 7ed485698a
commit 73d64e2987

View File

@@ -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)