Skip to content

armgit / krita

Public Imported from GitHub
0

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++

Skip ref image preview if its opacity = 0

Dat Le9c8094150645
diff --git a/libs/ui/tool/KisAsyncColorSamplerHelper.cpp b/libs/ui/tool/KisAsyncColorSamplerHelper.cpp
index d248b9ab73..a1cbea9e84 100644
--- a/libs/ui/tool/KisAsyncColorSamplerHelper.cpp
+++ b/libs/ui/tool/KisAsyncColorSamplerHelper.cpp
@@ -763,8 +763,8 @@ void KisAsyncColorSamplerHelper::paintCircleCanvasPreview(QPainter &gc, const QR
gc.restore();
}
-// Won't show opacity because the color sampled doesn't respect opacity either
-// TODO: Test if reference image still show when not visible, opacity = 0. Maybe we need to cover that too
+// Preview won't respect opacity because the color sampled doesn't respect opacity either
+// But if opacity = 0, preview for that image won't show at all
void KisAsyncColorSamplerHelper::paintCircleReferenceImagePreview(QPainter &gc, const QRectF &viewRectF, const QRectF &zoomDocRectF, const QPainterPath &clip) {
KisDocument *document = m_d->canvas->viewManager()->document();
if (!document || !document->referenceImagesLayer()) return;
@@ -781,6 +781,8 @@ void KisAsyncColorSamplerHelper::paintCircleReferenceImagePreview(QPainter &gc,
KisReferenceImage *refImage = dynamic_cast<KisReferenceImage*>(shape);
if (!refImage) continue;
+ if (refImage->transparency() == 1.0) continue;
+
gc.save();
QImage image = refImage->getCachedImage();
@@ -788,7 +790,7 @@ void KisAsyncColorSamplerHelper::paintCircleReferenceImagePreview(QPainter &gc,
QPoint refPixelPoint = refImage->documentToPixelFloored(zoomDocRectF.center());
// Avoid using KisReferenceImage::documentToPixel because it use absoluteTransformation.invert()
- // Which will take rotation into account and cause some quirks
+ // Which will take rotation into account and cause some quirks when ref image is rotated
qreal xScale = refImage->boundingRect().width() / image.width();
qreal yScale = refImage->boundingRect().height() / image.height();