Hello community,
I've just tried to make a simple box blur effect in pdn. My code is:
#region UICode
#endregion
void Render(Surface dst, Surface src, Rectangle rect)
{
// Delete any of these lines you don't need
Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
int CenterX = ((selection.Right - selection.Left) / 2)+selection.Left;
int CenterY = ((selection.Bottom - selection.Top) / 2)+selection.Top;
ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;
ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor;
int BrushWidth = (int)EnvironmentParameters.BrushWidth;
ColorBgra CurrentPixel;
ColorBgra LeftPixel;
ColorBgra RightPixel;
ColorBgra AbovePixel;
ColorBgra BelowPixel;
for (int y = rect.Top + 1; y < rect.Bottom - 1; y++)
{
for (int x = rect.Left + 1; x < rect.Right - 1; x++)
{
CurrentPixel = src[x,y];
LeftPixel = src[x-1,y];
AbovePixel = src[x,y-1];
BelowPixel = src[x,y+1];
RightPixel = src[x+1,y];
CurrentPixel.R = (byte)((LeftPixel.R+AbovePixel.R+BelowPixel.R+RightPixel.R)/4);
CurrentPixel.G = (byte)((LeftPixel.G+AbovePixel.G+BelowPixel.G+RightPixel.G)/4);
CurrentPixel.B = (byte)((LeftPixel.B+AbovePixel.B+BelowPixel.B+RightPixel.B)/4);
CurrentPixel.A = (byte)((LeftPixel.A+AbovePixel.A+BelowPixel.A+RightPixel.A)/4);
dst[x,y] = CurrentPixel;
}
}
}
But i don't know the reason, why it doesn't work correctly. It's so strange, because it's just working every 2y-coords.
I hope someone or BoltBait can help me:roll:
MfG whiterock
p.s: I'm from Austria