Commit cb16544f authored by Bart Coppens's avatar Bart Coppens

Convolution implementation for alpha colorspace, needed for feather selection

svn path=/trunk/koffice/; revision=443307
parent 4632e27b
......@@ -310,3 +310,23 @@ QString KisColorSpaceAlpha::normalisedChannelValueText(const Q_UINT8 *pixel, Q_U
return QString().setNum(static_cast<float>(pixel[channelPosition]) / UINT8_MAX);
}
void KisColorSpaceAlpha::convolveColors(Q_UINT8** colors, Q_INT32 * kernelValues, enumChannelFlags channelFlags, Q_UINT8 *dst, Q_INT32 factor, Q_INT32 offset, Q_INT32 nColors) const
{
Q_INT32 totalAlpha = 0;
while (nColors--)
{
Q_INT32 weight = *kernelValues;
if (weight != 0) {
totalAlpha += (*colors)[PIXEL_MASK] * weight;
}
colors++;
kernelValues++;
}
if (channelFlags & FLAG_ALPHA) {
dst[PIXEL_MASK] = CLAMP((totalAlpha/ factor) + offset, 0, QUANTUM_MAX);
}
}
......@@ -66,6 +66,8 @@ public:
virtual void adjustBrightnessContrast(const Q_UINT8 *src, Q_UINT8 *dst, Q_INT8 brightness, Q_INT8 contrast, Q_INT32 nPixels) const;
virtual void convolveColors(Q_UINT8** colors, Q_INT32* kernelValues, enumChannelFlags channelFlags, Q_UINT8 *dst, Q_INT32 factor, Q_INT32 offset, Q_INT32 nColors) const;
protected:
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment