Painting on selections and selection masks

Boudewijn Rempt boud at valdyas.org
Fri Oct 28 17:52:33 UTC 2011


On Friday 28 October 2011 Oct, Dmitry Kazakov wrote:

> Well, could you elaborate a bit on these problems. I see it to work as
> follows (point me where I'm wrong):
> 
> 1) Grayscale masks have single channel, that is treated by selections as
> usual.
> 2) When a tool decides to paint on a mask, it creates a dab, that is
> generated in a usual two-channel grayscale colorspace 

No, it tries to create a dab in the colorspace of the target paint device -- i.e., a one channel grayscale colorspace. This doesn't work. Nor do I believe is dab creation the only place where having no alpha channel gives problems.

I tried to special case dab creation -- i.e., check whether there's an alpha channel, if not, create the dab in the equivalent colorspace with alpha channel, and then convert the dab to a colorspace without the alpha channel, but that was, to me, very hacky.

> (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).
> 3) When a tool paints on the device, it uses special composition(s):
> grayscale_two_channel over grayscale_one_channel.

No, in practice, painting never converts any colorspace to any other colorspace since it already works in the target colorspace.

> It may look like (it's disputable which formula to use):
> 
> C_output = C_2 * alpha_2 + C_1 * (1 - alpha_2),
> where
> *_2 indexes refer to "2-channel" colorspace of the dab
> *_1 indexes refer to "1-channel" colorspace of the mask
> 
> 
> 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.

If I understand your proposition correctly you want to add an extra method to KisPaintDevice, something like "dabColorSpace"?

I don't think that design will be solid -- not when the rest of Krita thinks it will always find an alpha channel. Just check the code for the outline generator, for instance...

-- 
Boudewijn Rempt
http://www.valdyas.org, http://www.krita.org, http://www.boudewijnrempt.nl


More information about the kimageshop mailing list