63 void convolveColors(
const quint8*
const* colors,
const qreal* kernelValues, quint8 *dst, qreal factor, qreal offset, qint32 nPixels,
const QBitArray & channelFlags)
const override {
66 qreal totals[_CSTrait::channels_nb];
68 qreal totalWeight = 0;
69 qreal totalWeightTransparent = 0;
71 memset(totals, 0,
sizeof(qreal) * _CSTrait::channels_nb);
73 for (; nPixels--; colors++, kernelValues++) {
74 qreal weight = *kernelValues;
77 if (_CSTrait::opacityU8(*colors) == 0) {
78 totalWeightTransparent += weight;
80 for (
uint i = 0; i < _CSTrait::channels_nb; i++) {
81 totals[i] += color[i] * weight;
84 totalWeight += weight;
88 typename _CSTrait::channels_type* dstColor = _CSTrait::nativeArray(dst);
90 bool allChannels = channelFlags.isEmpty();
91 Q_ASSERT(allChannels || channelFlags.size() == (
int)_CSTrait::channels_nb);
92 if (totalWeightTransparent == 0) {
94 for (
uint i = 0; i < _CSTrait::channels_nb; i++) {
95 if (allChannels || channelFlags.testBit(i)) {
101 }
else if (totalWeightTransparent != totalWeight) {
102 if (totalWeight == factor) {
104 qint64 a = (totalWeight - totalWeightTransparent);
105 for (
uint i = 0; i < _CSTrait::channels_nb; i++) {
106 if (allChannels || channelFlags.testBit(i)) {
107 if (i == (
uint)_CSTrait::alpha_pos) {
120 qreal a = qreal(totalWeight) / (factor * (totalWeight - totalWeightTransparent));
121 for (
uint i = 0; i < _CSTrait::channels_nb; i++) {
122 if (allChannels || channelFlags.testBit(i)) {
123 if (i == (
uint)_CSTrait::alpha_pos) {