/*
* feConvolveMatrix filter primitive renderer
*
* Authors:
* Felipe CorrĂȘa da Silva Sanches <juca@members.fsf.org>
* Jasper van de Gronde <th.v.d.gronde@hccnet.nl>
*
* Copyright (C) 2007,2009 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <vector>
#include "display/cairo-templates.h"
#include "display/cairo-utils.h"
#include "display/nr-filter-convolve-matrix.h"
#include "display/nr-filter-slot.h"
#include "display/nr-filter-units.h"
#include "display/nr-filter-utils.h"
namespace Inkscape {
namespace Filters {
{}
return new FilterConvolveMatrix();
}
{}
enum PreserveAlphaMode {
};
template <PreserveAlphaMode preserve_alpha>
: SurfaceSynth(s)
{
}
// the matrix is given rotated 180 degrees
// which corresponds to reverse element order
}
guint32 operator()(int x, int y) const {
for (int i = 0; i < limity; ++i) {
for (int j = 0; j < limitx; ++j) {
EXTRACT_ARGB32(px, a,r,g,b)
if (preserve_alpha == NO_PRESERVE_ALPHA) {
}
}
}
if (preserve_alpha == PRESERVE_ALPHA) {
} else {
}
return pxout;
}
private:
double _bias;
};
{
static bool bias_warning = false;
static bool edge_warning = false;
g_warning("Empty kernel!");
return;
}
g_warning("Invalid target!");
return;
}
//g_warning("kernelMatrix does not have orderX*orderY elements!");
return;
}
// We may need to transform input surface to correct color interpolation space. The input surface
// might be used as input to another primitive but it is likely that all the primitives in a given
// filter use the same color interpolation space so we don't copy the input before converting.
if( _style ) {
}
if (bias!=0 && !bias_warning) {
g_warning("It is unknown whether Inkscape's implementation of bias in feConvolveMatrix "
"is correct!");
bias_warning = true;
// 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
}
g_warning("Inkscape only supports edgeMode=\"none\" (and a filter uses a different one)!");
edge_warning = true;
}
//guint32 *in_data = reinterpret_cast<guint32*>(cairo_image_surface_get_data(input));
//guint32 *out_data = reinterpret_cast<guint32*>(cairo_image_surface_get_data(out));
//int width = cairo_image_surface_get_width(input);
//int height = cairo_image_surface_get_height(input);
// Set up predivided kernel matrix
/*std::vector<double> kernel(kernelMatrix);
for(size_t i=0; i<kernel.size(); i++) {
kernel[i] /= divisor; // The code that creates this object makes sure that divisor != 0
}*/
if (preserveAlpha) {
//convolve2D<true>(out_data, in_data, width, height, &kernel.front(), orderX, orderY,
// targetX, targetY, bias);
} else {
//convolve2D<false>(out_data, in_data, width, height, &kernel.front(), orderX, orderY,
// targetX, targetY, bias);
}
}
}
}
}
}
divisor = d;
}
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.
// adjusting the boundary conditions).
}
{
return kernelMatrix.size();
}
} /* 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:fileencoding=utf-8:textwidth=99 :