{
return null;
}
ImageData output = source.copy();
final CanvasPixelArray srcd = source.getData();
if (null == srcd)
{
return source;
}
final CanvasPixelArray dstd = output.getData();
if (null == dstd)
{
return source;
}
int side = (int) (Math.sqrt(m_weights.length) + 0.5);
int half = (int) (Math.floor(side / 2));
int sw = source.getWidth();
int sh = source.getHeight();
int w = sw;
int h = sh;
for (int y = 0; y < h; y++)
{
for (int x = 0; x < w; x++)
{
int sy = y;
int sx = x;
int dsto = (y * w + x) * 4;
int r = 0, g = 0, b = 0;
for (int cy = 0; cy < side; cy++)
{
for (int cx = 0; cx < side; cx++)
{
int scy = sy + cy - half;
int scx = sx + cx - half;
if (scy >= 0 && scy < sh && scx >= 0 && scx < sw)
{
int srco = (scy * sw + scx) * 4;
double wt = m_weights[cy * side + cx];
r += srcd.get(srco + R_OFFSET) * wt;
g += srcd.get(srco + G_OFFSET) * wt;
b += srcd.get(srco + B_OFFSET) * wt;
}
}
}
dstd.set(dsto + R_OFFSET, r);
dstd.set(dsto + G_OFFSET, g);
dstd.set(dsto + B_OFFSET, b);
}
}
return output;
}