[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-kimageshop
Subject:    Patch for smudge
From:       "LukasT.dev () gmail ! com" <lukast ! dev () gmail ! com>
Date:       2010-09-22 17:04:09
Message-ID: 201009221904.09732.LukasT.dev () gmail ! com
[Download RAW message or body]

Hello,

today I was working on bug https://bugs.kde.org/show_bug.cgi?id=245130
that is unsolved part of the major bug 217124.

I come up with something like you can see in the attachment.

The behaviour of the smudge is now different in that sense that now the 
transparency of the colors run out much faster. I don't know if we want that, 
that's why I want you to test the patch and get some feedback.

What to test before and after applying the patch.

1. Edit-> clear to have transparent layer
2. draw big red dot somewhere
3. smudge from red dot to transparent area in NORMAL mode
4. smudge from red dot to transparent area in COPY mode
5. smudge from transparent area to red dot in NORMAL mode
6. smudge from transparent area to red dot in COPY mode
7. Report back
8. Have some candies

What I did: Instead of changing the pixel transparency per pixel, I added 
opacity of the painter that is changed according the rate option.
It's not exactly the same thing that used to happen -- because you can notice 
that the opacity is raised per pixel when we bitBlit part of the layer data 
with copy painter.

It solves the problem of mixing transparent pixels to colours.

It has some blocky effect (also visible before) but that is not important now, 
I will be important when we decide to go this path.

Have you got ideas for different solution or what should I test?
I'm thinking about changing the opacity of the mask pixels maybe?
I did not managed to test it yet though.



["different-smudge.patch" (text/x-patch)]

diff --git a/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.cpp \
b/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.cpp index \
                ba7218d..4b0b85a 100644
--- a/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.cpp
+++ b/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.cpp
@@ -66,10 +66,9 @@ KisSmudgeOp::KisSmudgeOp(const KisBrushBasedPaintOpSettings \
*settings, KisPainte  
     m_tempDev = new KisPaintDevice(painter->device()->colorSpace());
     
-    // Initializing to a valid value to avoid weird errors during modifications
-    m_wholeTempData = QRect(0, 0, 0, 0);
-    
     m_color = painter->paintColor();
+    
+    m_painterOpacity = OPACITY_OPAQUE_U8;
 }
 
 KisSmudgeOp::~KisSmudgeOp()
@@ -148,33 +147,18 @@ double KisSmudgeOp::paintAt(const KisPaintInformation& info)
     /* In the block below, the opacity of the colors stored in m_tempDev
     is reduced in opacity. Nothing of the color present inside it is left out */
     quint8 opacity = OPACITY_OPAQUE_U8;
+    
     if (!m_firstRun) {
         opacity = m_rateOption.apply(opacity, info);
         /* Without those limits, the smudge brush doesn't smudge anymore, it either \
                makes a single
         dropplet of color, or drags a frame indefinitely over the canvas. */
         opacity = qBound(MIXABLE_LOWER_LIMIT, opacity, MIXABLE_UPPER_LIMIT);
         
-        // Update the whole temporary data area, only grow it, don't shrink it. \
                TODO: Shrink it when relevant
-        QRect currentTempDataRect = QRect(extractionTopLeft, \
                maskDab->bounds().size());
-        if (currentTempDataRect.contains(m_wholeTempData)) {
-            m_wholeTempData = currentTempDataRect;
-        }
-        
-        // Reduce the opacity of all the data contained therein
-        KisRectIterator it = m_tempDev->createRectIterator(m_wholeTempData.x(), \
                m_wholeTempData.y(),
-                                                           m_wholeTempData.width(), \
                m_wholeTempData.height());
-        KoColorSpace* cs = m_tempDev->colorSpace();
-        while (!it.isDone()) {
-            cs->setOpacity(it.rawData(), quint8(cs->opacityF(it.rawData()) * \
                opacity), 1);
-            ++it;
-        }
-        
-        // Invert the opacity value for color absorption in the next lines \
(copyPainter) +        m_painterOpacity = m_painterOpacity/qreal(OPACITY_OPAQUE_U8) * \
opacity;  opacity = OPACITY_OPAQUE_U8 - opacity;
     }
     else {
         m_firstRun = false;
-        m_wholeTempData = QRect(extractionTopLeft, maskDab->bounds().size());
     }
                                       
     /* copyPainter will extract the piece of color (image) to be duplicated to \
generate the smudge effect, @@ -184,9 +168,15 @@ double KisSmudgeOp::paintAt(const \
KisPaintInformation& info)  copyPainter.setOpacity(opacity);
     copyPainter.bitBlt(extractionTopLeft.x(), extractionTopLeft.y(), \
painter()->device(), x, y, sw, sh);  copyPainter.end();
+    //TODO: we lowered the opacity per pixel, but here we add some opacity back, \
maybe we should add some opacity to painterOpacity too? +    //quint8 fullOpacity = \
OPACITY_OPAQUE_U8; +    \
//maskDab->colorSpace()->compositeOp(COMPOSITE_OVER)->composite(&m_painterOpacity,mask \
Dab->colorSpace()->pixelSize(),&fullOpacity,maskDab->colorSpace()->pixelSize(),0,0,1,1,opacity);
  
     // This is the line that renders the extracted colors to the screen, with \
maskDab giving it the brush shape +    quint8 origOpacity = painter()->opacity();
+    painter()->setOpacity(m_painterOpacity);
     painter()->bitBltWithFixedSelection(x, y, m_tempDev, maskDab, 0, 0, \
extractionTopLeft.x(), extractionTopLeft.y(), sw, sh); +    \
painter()->setOpacity(origOpacity);  
     return spacing(scale);
 }
diff --git a/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.h \
b/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.h index 3b49bb7..ccd1ace \
                100644
--- a/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.h
+++ b/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.h
@@ -52,8 +52,9 @@ private:
     // The "temporary paint device"
     KisPaintDeviceSP m_tempDev;
     // The size of the rectangle encompassing the whole data in the temporary device \
                needs to be cached for speed
-    QRect m_wholeTempData;
     KoColor m_color;
+
+    quint8 m_painterOpacity;
     
     KisPressureSizeOption m_sizeOption;
     KisPressureOpacityOption m_opacityOption;



_______________________________________________
kimageshop mailing list
kimageshop@kde.org
https://mail.kde.org/mailman/listinfo/kimageshop


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic