|
|
@ -80,12 +80,13 @@ namespace ImageProcessor.Filters |
|
|
{ |
|
|
{ |
|
|
for (int x = startX; x < endX; x++) |
|
|
for (int x = startX; x < endX; x++) |
|
|
{ |
|
|
{ |
|
|
float rX = 0; |
|
|
float red = 0; |
|
|
float gX = 0; |
|
|
float green = 0; |
|
|
float bX = 0; |
|
|
float blue = 0; |
|
|
|
|
|
float alpha = 0; |
|
|
|
|
|
|
|
|
// Apply each matrix multiplier to the color components for each pixel.
|
|
|
// Apply each matrix multiplier to the color components for each pixel.
|
|
|
for (int fy = 0; fy < kernelHeight; fy++) |
|
|
for (int fy = 0; fy < kernelHeight; fy++) |
|
|
{ |
|
|
{ |
|
|
int fyr = fy - radiusY; |
|
|
int fyr = fy - radiusY; |
|
|
int offsetY = y + fyr; |
|
|
int offsetY = y + fyr; |
|
|
@ -100,22 +101,15 @@ namespace ImageProcessor.Filters |
|
|
offsetX = offsetX.Clamp(0, maxX); |
|
|
offsetX = offsetX.Clamp(0, maxX); |
|
|
|
|
|
|
|
|
Color currentColor = source[offsetX, offsetY]; |
|
|
Color currentColor = source[offsetX, offsetY]; |
|
|
float r = currentColor.R; |
|
|
|
|
|
float g = currentColor.G; |
|
|
|
|
|
float b = currentColor.B; |
|
|
|
|
|
|
|
|
|
|
|
rX += kernel[fy, fx] * r; |
|
|
red += kernel[fy, fx] * currentColor.R; |
|
|
gX += kernel[fy, fx] * g; |
|
|
green += kernel[fy, fx] * currentColor.G; |
|
|
bX += kernel[fy, fx] * b; |
|
|
blue += kernel[fy, fx] * currentColor.B; |
|
|
|
|
|
alpha += kernel[fy, fx] * currentColor.A; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
float red = rX; |
|
|
target[x, y] = new Color(red, green, blue, alpha); |
|
|
float green = gX; |
|
|
|
|
|
float blue = bX; |
|
|
|
|
|
|
|
|
|
|
|
Color targetColor = target[x, y]; |
|
|
|
|
|
target[x, y] = new Color(red, green, blue, targetColor.A); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|