nr-filter-convolve-matrix.cpp revision a0ce949d080eec8c6fd4d7e13ac24579c8e706ba
/*
* feConvolveMatrix filter primitive renderer
*
* Authors:
* Felipe CorrĂȘa da Silva Sanches <felipe.sanches@gmail.com>
*
* Copyright (C) 2007 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "display/nr-filter-convolve-matrix.h"
#include "display/nr-filter-units.h"
#include "display/nr-filter-utils.h"
#include <vector>
namespace Inkscape {
namespace Filters {
{}
return new FilterConvolveMatrix();
}
{}
if (!in) {
return 1;
}
if (bias!=0) {
g_warning("It is unknown whether Inkscape's implementation of bias in feConvolveMatrix is correct!");
// The SVG specification implies that feConvolveMatrix is defined for premultiplied colors (which makes sense).
// It also says that bias should simply be added to the result for each color (without taking the alpha into account)
// However, it also says that one purpose of bias is "to have .5 gray value be the zero response of the filter".
// It seems sensible to indeed support the latter behaviour instead of the former, but this does appear to go against the standard.
// Note that Batik simply does not support bias!=0
}
true);
double result_R = 0;
double result_G = 0;
double result_B = 0;
double result_A = 0;
for (unsigned int i=0; i < orderY; i++){
for (int j=0; j < orderX; j++){
}
}
if( preserveAlpha ) {
} else {
}
out_data[out_index+0] = CLAMP_D_TO_U8_ALPHA(result_R / divisor + out_data[out_index+3]*bias, out_data[out_index+3]); // CLAMP includes rounding!
out_data[out_index+1] = CLAMP_D_TO_U8_ALPHA(result_G / divisor + out_data[out_index+3]*bias, out_data[out_index+3]);
out_data[out_index+2] = CLAMP_D_TO_U8_ALPHA(result_B / divisor + out_data[out_index+3]*bias, out_data[out_index+3]);
}
}
} else {
double result_R = 0;
double result_G = 0;
double result_B = 0;
double result_A = 0;
for (unsigned int i=0; i < orderY; i++){
for (unsigned int j=0; j < orderX; j++){
}
}
if( preserveAlpha ) {
} else {
}
} else {
out_data[out_index+0] = CLAMP_D_TO_U8(result_R / (divisor*out_data[out_index+3]) + 255*bias); // CLAMP includes rounding!
}
}
}
}
return 0;
}
}
}
}
}
void FilterConvolveMatrix::set_divisor(double d) {
divisor = d;
}
void FilterConvolveMatrix::set_bias(double b) {
bias = b;
}
kernelMatrix = km;
}
}
preserveAlpha = pa;
}
{
//Seems to me that since this filter's operation is resolution dependent,
// some spurious pixels may still appear at the borders when low zooming or rotating. Needs a better fix.
}
return TRAIT_PARALLER;
}
} /* namespace Filters */
} /* namespace Inkscape */
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :