[graphics/krita] libs/ui/tool: Fix preview size on canvas jumping around because of rounding errors
Emmet O'Neill <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 749a248f16b75b1e58a2041f24dc92549752bd99 by Emmet O'Neill, on behalf of Dat Le.
Committed on 13/08/2026 at 23:16.
Pushed by emmetoneill into branch 'master'.
Fix preview size on canvas jumping around because of rounding errors
M +6 -2 libs/ui/tool/KisAsyncColorSamplerHelper.cpp
https://invent.kde.org/graphics/krita/-/commit/749a248f16b75b1e58a2041f24dc92549752bd99
diff --git a/libs/ui/tool/KisAsyncColorSamplerHelper.cpp b/libs/ui/tool/KisAsyncColorSamplerHelper.cpp
index aac74fbc075..95501e80e58 100644
--- a/libs/ui/tool/KisAsyncColorSamplerHelper.cpp
+++ b/libs/ui/tool/KisAsyncColorSamplerHelper.cpp
@@ -741,10 +741,14 @@ QImage KisAsyncColorSamplerHelper::cacheCanvasImage(QRect &canvasPixelRect) {
void KisAsyncColorSamplerHelper::paintCircleCanvasPreview(QPainter &gc, const QRectF &viewRectF, const QRectF &zoomDocRectF, const QPainterPath &clip) {
KisImageWSP image = m_d->canvas->image();
- QRect canvasPixelRect = image->documentToPixel(zoomDocRectF).toRect();
+ QRectF canvasPixelRectF = image->documentToPixel(zoomDocRectF);
+
+ // Floor manually to avoid width != height when using toRect()
+ QRect canvasPixelRect = QRect(canvasPixelRectF.topLeft().toPoint(), QSize(qFloor(canvasPixelRectF.width()), qFloor(canvasPixelRectF.height())));
+
canvasPixelRect = m_d->standardizeZoomPreviewPixelRect(canvasPixelRect);
- // Make sure the center is the pixel currently sampled (in case of rounding errors)
+ // Make sure the center is the pixel currently sampled because standardizing may change the shape
canvasPixelRect.moveCenter(image->documentToImagePixelFloored(zoomDocRectF.center()));
QImage cachedImage = cacheCanvasImage(canvasPixelRect);