Solution for the grayscale selections

Dmitry Kazakov dimula73 at gmail.com
Tue Sep 25 08:07:57 UTC 2012


Hi!

I started fixing the grayscale selections problem yesterday. We've
discussed the details of it several times already, so I'll try not to write
too much. So, the working solution is the following:

1) Every paint device has an additional method paintingColorSpace(). This
method tells the painting tools which colorspace they should use for their
dabs.
2) Some KoCompositeOp's have an ability to work cross-colorspace, that is
with the source in one colorspace and the destination in the other. The
alpha8 colorspace has such compositeOps. The methods are:

    /**
     * Returns true if the composite op can write pixels into the parent
     * colorspace from a colorspace \p srcSpace. If this function returns
     * true, then a special method
     * composite(const ParameterInfo&, const KoColorSpace*)
     * becomes available to the user. Otherwise the CS should be
     * converted before calling a usual composite() method
     *
     * \see composite(const ParameterInfo&, const KoColorSpace*)
     */
    virtual bool supportsCrossColorspaceComposition(const KoColorSpace*
srcSpace) const;

    /**
     * Composes pixels from any arbitrary colorspace \p srcSpace
     * to the destination buffer. It is available only in case
     * supportsCrossColorspaceComposition() returns true
     */
    virtual void composite(const ParameterInfo& params, const KoColorSpace*
srcSpace) const;

3) The selection nodes still keeps the alpha8 colorspace for their paint
devices, but return a grayscale8 colorspace as their painting colorspace.
In a result, the bitBlt operation for the dabs will convert the pixels
right.

The only trouble I see here is that in all the paintOps I'll have to change
device()->colorSpace() to device->paintingColorSpace(), which is quite
doable.

So what do you think of it?

-- 
Dmitry Kazakov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kimageshop/attachments/20120925/3a99490a/attachment.html>


More information about the kimageshop mailing list