Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Fix preview size on canvas jumping around because of rounding errors
Dat Le749a248f16b7
diff --git a/libs/ui/tool/KisAsyncColorSamplerHelper.cpp b/libs/ui/tool/KisAsyncColorSamplerHelper.cppindex aac74fbc07..95501e80e5 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 shapecanvasPixelRect.moveCenter(image->documentToImagePixelFloored(zoomDocRectF.center()));QImage cachedImage = cacheCanvasImage(canvasPixelRect);