Solution for the grayscale selections

Cyrille Berger cberger at cberger.net
Tue Sep 25 09:19:30 UTC 2012


On Tue, 25 Sep 2012 10:58:27 +0200 (CEST), Boudewijn Rempt
<boud at valdyas.org> wrote:
> On Tue, 25 Sep 2012, Dmitry Kazakov wrote:
> 
>>
>>       Well, you know what I think of this idea already, since we
>>       discussed it before
>>
>>       For this problem I think there are two decent solutions:
>>
>>       1) make Krita work with premultiplied alpha colorspaces (i.e.,
>>       colorspaces with no separate alpha channel). This is a lot of
work,
>>       but it is the proper solution.
>> 
>> 
>> Well, "premultipled alpha" usually means not "colorspaces with no
>> separate alpha channel", but colorspaces stored in a form of
>> (ra,ga,ba,a). If you have no alpha channel at all, you will simply not
be
>> able to do COMPOSITE_OVER,
>> because it uses the source alpha even in premultiplied case. Just
>> mathematically. So the premultiplication will give us no help.
> 
> Given that other applications can paint on rgb or gray paint devices 
> without an alpha channel, using the "over" composite op, it should be 
> possible for us to fix pigment to make that work as well. That is the 
> real and proper solution. It's also the most difficult one, which is why
I 
> first investigated the projection solution.

That does not require to use premultiplied alpha. In that case it is just
assumed that alpha = 255.

Right now, composite op assumes that source colour space == destination
colour space. But there is no reason why we can't change that specific
behaviour. I would do the following:

* in KoCompositeOp, add an optional parameter for a destination colour
space
* in KoColorSpace::bitBlt, if source colour space != destination, check if
there is a composite op that can work across those two colour spaces
* implement a "gray" only colour space, and a GRAYA on GRAY composite op,
that assumes that GRAY's alpha channel is set to 255 all the time.

-- 
Cyrille Berger


More information about the kimageshop mailing list