GMIC in Krita
Boudewijn Rempt
boud at valdyas.org
Sun Apr 14 17:32:08 UTC 2013
On Sun, 14 Apr 2013, Lukast dev wrote:
>>> So my approach will be:
>>> a) convert layer actual color-space to FLOAT32 RGB(A), relayout pixel
>>> format (Krita uses bgrbgrbgrbgr, GMIC rrrrbbbbgggg)
>>
>>
>> Hm, I don't think so. Specially for float32 I created KoRgbF32Traits --
>> this means that the f32 and f16 colorspaces layout the pixel as rgba:
>>
>> addChannel(new KoChannelInfo(i18n("Red") , 0 * sizeof(float), 0,
>> KoChannelInfo::COLOR, KoChannelInfo::FLOAT32, 4, QColor(255, 0, 0)));
>> addChannel(new KoChannelInfo(i18n("Green"), 1 * sizeof(float), 1,
>> KoChannelInfo::COLOR, KoChannelInfo::FLOAT32, 4, QColor(0, 255, 0)));
>> addChannel(new KoChannelInfo(i18n("Blue") , 2 * sizeof(float), 2,
>> KoChannelInfo::COLOR, KoChannelInfo::FLOAT32, 4, QColor(0, 0, 255)));
>> addChannel(new KoChannelInfo(i18n("Alpha"), 3 * sizeof(float), 3,
>> KoChannelInfo::ALPHA, KoChannelInfo::FLOAT32, 4));
>>
>> So not much conversion needed, I think
>
> Well, it still layout pixels in 2x2 image like this:
>
> rgbargbargbargba
>
> but GMIC asks for
>
> rrrrggggbbbbaaaa
>
Ah! Now I get you. But that is already provided for, too, by:
/**
* Copy the bytes in the paint device into a vector of arrays of
bytes,
* where the number of arrays is the number of channels in the
* paint device. If the specified area is larger than the paint
* device's extent, the default pixel will be read.
*/
QVector<quint8*> readPlanarBytes(qint32 x, qint32 y, qint32 w, qint32
h);
/**
* Write the data in the separate arrays to the channes. If there
* are less vectors than channels, the remaining channels will not
* be copied. If any of the arrays points to 0, the channel in
* that location will not be touched. If the specified area is
* larger than the paint device, the paint device will be
* extended. There are no guards: if the area covers more pixels
* than there are bytes in the arrays, krita will happily fill
* your paint device with areas of memory you never wanted to be
* read. Krita may also crash.
*
* XXX: what about undo?
*/
void writePlanarBytes(QVector<quint8*> planes, qint32 x, qint32 y,
qint32 w, qint32 h);
Not absolutely completely efficient, of course, but this is the right
thing to do. And I should spell-check the apidox and remove that XXX
:-).
Boud
More information about the kimageshop
mailing list