[graphics/krita] libs/ui/tool: Figured out how to convert shape coord into pixel
Emmet O'Neill <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 8d26255715e7ae5e426fcfe1428071b9332aa806 by Emmet O'Neill, on behalf of Le Tien Dat.
Committed on 13/08/2026 at 23:16.
Pushed by emmetoneill into branch 'master'.
Figured out how to convert shape coord into pixel
M +7 -4 libs/ui/tool/KisAsyncColorSamplerHelper.cpp
https://invent.kde.org/graphics/krita/-/commit/8d26255715e7ae5e426fcfe1428071b9332aa806
diff --git a/libs/ui/tool/KisAsyncColorSamplerHelper.cpp b/libs/ui/tool/KisAsyncColorSamplerHelper.cpp
index bfea94c4bbd..67906023ccb 100644
--- a/libs/ui/tool/KisAsyncColorSamplerHelper.cpp
+++ b/libs/ui/tool/KisAsyncColorSamplerHelper.cpp
@@ -570,14 +570,17 @@ void KisAsyncColorSamplerHelper::paintCircle(QPainter &gc,
// TODO: Figure out how to convert shape coordinate to pixel coordinate
// Just need to divide by scale. How to find the scale though
QImage image = refImage->getImage();
+ qreal xScale = refImage->boundingRect().width() / image.width();
+ qreal yScale = refImage->boundingRect().height() / image.height();
QRectF refRectF = refImage->documentToShape(sampleDocRectF);
dbgUI << "Shape coordinate: " << refRectF;
+ dbgUI << "Image scaling: " << refImage->transformation().m11();
QPointF topLeft = refRectF.topLeft();
- topLeft.setX(topLeft.x() * image.width());
- topLeft.setY(topLeft.y() * image.height());
+ topLeft.setX(topLeft.x() / xScale);
+ topLeft.setY(topLeft.y() / yScale);
QPointF bottomRight = refRectF.bottomRight();
- bottomRight.setX(bottomRight.x() * image.width());
- bottomRight.setY(bottomRight.y() * image.height());
+ bottomRight.setX(bottomRight.x() / xScale);
+ bottomRight.setY(bottomRight.y() / yScale);
dbgUI << "Shape pixel coordinate: " << QRectF(topLeft, bottomRight);