<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Hi Dmitry,<br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /><br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">On Friday 04 September 2009, Dmitry Kazakov wrote:<br />&gt; There are two solutions for that.<br />&gt;<br />&gt; 1) Most obvious way. Just use grayscale8 colorspace for KisSelection's<br />&gt; paintDevice. The second problem will be solved in a natural way. But<br />&gt; this system has a huge drawback. Much code of Krita uses direct access<br />&gt; to selection's transparency pixels (that is not so good in general).<br />&gt; The calls are done like:<br />&gt; selection()-&gt;pixel()-&gt;alpha()<br />&gt; ALL THIS CALLS will have to be changed to:<br />&gt; selection()-&gt;pixel()-&gt;gray()<br />&gt; That is possible, but quite difficult.<br />Any code example of that ? Because, to me this sounds like a wrong construct, everywhere we should access selectiveness through iterators, and then the only requirement for the color space of the mask/selection is to be single channel unsigned interger 8bit. Was it what you meant ?<br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /><br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&gt; 2) The second way is not so obvious and needs some help from<br />&gt; Cyrille. This solution leaves KisSelection's paintDevice in alpha8()<br />&gt; colorspace. BUT all the painting and bitBlt'ing into this device will<br />&gt; be done through a special type of a grayscale colorspace, let's call<br />&gt; it transparencyColorspace(TCS). This TCS will have two channels: gray<br />&gt; and alpha. Gray-channel accumulates rgb-values of the brush and alpha<br />&gt; channel controls the shape of the brush. The only difference of TCS<br />&gt; from usual grayscale CS is the way it is converted into alpha8() CS.<br />&gt;<br />&gt; Usual grayscale CS:<br />&gt; GCS        alpha8()<br />&gt; Gray  -&gt; [/dev/null]<br />&gt; Alpha -&gt; alpha<br />&gt;<br />&gt; Our TCS:<br />&gt; TCS        alpha8()<br />&gt; Gray  -&gt; alpha<br />&gt; Alpha -&gt; [used by compositeOp's]<br />&gt;<br />&gt; The question is: which way to choose?<br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /><br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">I don't like 2). It sounds like a hack. And we will pay a high price for it, I fear. Lets go and think about a clean solution :) I think my proposal is close to what you mention in 1), except that I am unsure which grayscale color space you were thinking about, and for me it's clear that we have to keep mask/selection as single 8 bit uint channel. Since, for the reason you gave, alpha isn't the good colorspace, the only other colorspace that would qualify is "Grayscale 8bit without alpha".<br />Using that colorspace, drawing a gradient will work nicely. What doesn't work, and anyway need to be fixed, is painting. The problem is that composite op are assuming that the source color space and the destination colorspace are the same, and when we ask for compositing pixels with two different colorspaces, then pigment silently convert the source to the destination colorspaces, and then call the composite op. What I propose is to change that behaviour, and allow to write composite op that work with two different colorspaces. We also have  to change paintops to use  Gray8Alpha for the dab when painting on a Gray8 colorspace.<br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /><br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">-- <br />Cyrille Berger<br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /><br /></p><br /><br>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html>