Hi!<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I've been doing quite a bit of work in this area, first building on Sven's branch, then doing some other experiments. Here are my provisional conclusions and a proposed (less than ideal) solution:<br>
<br>
<br>
* tools cannot handle colorspaces without an alpha channel. We cannot generate a dab, we can't do anything. It's a limitation in our design.<br>
* pigment cannot handle masks with more than one channel. Again, nothing we can do much about.<br>
* the actual problem when painting on a gray without alpha colorspace paintdevice isn't the color conversion code or the bitblt implementation but that we cannot generate the right dabs or interpret the canvas correctly for painting. Again, we need an alpha channel to be able to paint.<br>

<br>
Just fixing the gray-without-alpha colorspace, or adding a special composite op will not fix the problems...<br></blockquote><div><br>Well, could you elaborate a bit on these problems. I see it to work as follows (point me where I'm wrong):<br>
<br>1) Grayscale masks have single channel, that is treated by selections as usual.<br>2) When a tool decides to paint on a mask, it creates a dab, that is generated in a usual two-channel grayscale colorspace (the "bit'ness" of the colorspace should coincide the same parameter of the mask, I guess, currently, for selections we have 8 bit channels without any options).<br>
3) When a tool paints on the device, it uses special composition(s): grayscale_two_channel over grayscale_one_channel.<br>It may look like (it's disputable which formula to use):<br><br>C_output = C_2 * alpha_2 + C_1 * (1 - alpha_2),<br>
where <br>*_2 indexes refer to "2-channel" colorspace of the dab <br>*_1 indexes refer to "1-channel" colorspace of the mask<br><br><br>What is the problem here? Tools can get a colorspace of the dab for the node using an additional method of KisNode. We can add it if needed.<br>
<br><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
I have tried to special case the painting code to generate a dab in graya and then convert to gray and then bitblt, but I disliked the fact that we then need to check all over the code for problems handling colorspaces without alpha.<br>

<br>
I took a look to see how hard it would be to make krita just work correctly with colorspaces without alpha but I gave up on that. Not feasible for 2.4, maybe just not feasible.<br>
<br>
I'm right now trying the following solution:<br>
<br>
* make KisPixelSelection have a gray + alpha colorspace and use this for creating selections<br>
* create a KisSelectionProjection class which is used for masking. KisSelection::projection returns an instance of this class<br>
<br>
This seems to be promising: I have a problem with the extent calculation of KisPixelSelection if it's graya, but apart from that nothing major. I think I can make this scheme work in time for 2.4.<br>
<br>
However, this means that a simple raster selection now takes not one, but _three_ bytes, and that there's always the step of generating the projection, which takes time.<br>
<br>
On the other hand, in the future it would make it much easier to make it possible to add, say, a blur filter mask to a transparency mask or apply filters to masks.<br>
<br>
On a sidenote: the outline generator needs to be rewritten so it doesn't need a copy of all the bytes in a selection as a buffer but to use a paint device. This is wasteful of memory.<br>
<br>
I've attached the current patchset, it doesn't work, but does give you a general idea.<br>
<font color="#888888">--<br>
Boudewijn Rempt<br>
<a href="http://www.valdyas.org" target="_blank">http://www.valdyas.org</a>, <a href="http://www.krita.org" target="_blank">http://www.krita.org</a>, <a href="http://www.boudewijnrempt.nl" target="_blank">http://www.boudewijnrempt.nl</a><br>

</font><br>_______________________________________________<br>
kimageshop mailing list<br>
<a href="mailto:kimageshop@kde.org">kimageshop@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/kimageshop" target="_blank">https://mail.kde.org/mailman/listinfo/kimageshop</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Dmitry Kazakov<br>