API problems with krita

Boudewijn Rempt boud at valdyas.org
Wed Jan 24 16:16:55 CET 2007


On Wednesday 24 January 2007 15:35, Schleimer, Ben wrote:
> Hi,
>   I am in the process of building a plugin for krita
> and I want to share a annoyance/ difficulity i found:
> ----------------
> KisColorSpace doesn't have any method for
> symmetrically extracting out and putting in a
> component of a pixel. So all symmetrical component
> operations have to be done with with:
>   a) KisPaintDevice::convertToQImage/convertFromQImage
> - which ignores higher precision for 16bit images
>   b) KisColorSpace::fromQColor/toQColor - same problem
> as above and difficult to use.
>
> Ideally, KisColorSpace and KisIteratorPixelTrait could
> be used together to set/get pixels from KisPaintDevice
>
> Should I file this as a bug?

It's actually a design problem, not a bug: as Casper says, there are plenty 
colorspaces where familiar per-channel algorithms don't work, which is why we 
build the algorithms in the colorspaces (and in 2.0, that will be done in an 
extensible way).

That said, you can get at the individual channels of a pixel:

QValueVector<KisChannelInfo *> channels();

gives you a vector that describes all channels, including their sizes in 
bytes, so you can use that to pointer-arithmetic yourself through the pixel 
pointed to by an iterator.

And there are the following three methods that may be of use:

This returns the value of a given component scaled to 8 bits:
Q_UINT8 scaleToU8(const Q_UINT8 * srcPixel, Q_INT32 channelPos);

This returns the value of a given component scaled to 16 bits:
Q_UINT16 scaleToU16(const Q_UINT8 * srcPixel, Q_INT32 channelPos);

This copies this value of a single channel into a destination pixel:
void getSingleChannelPixel(Q_UINT8 *dstPixel, const Q_UINT8 *srcPixel, 
Q_UINT32 channelIndex) = 0;

(Which means you can use it to put values into your data, too)

-- 
Boudewijn Rempt 
http://www.valdyas.org/fading/index.cgi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kimageshop/attachments/20070124/80e2d3d4/attachment.pgp 


More information about the kimageshop mailing list