Brightness
What it does
The Brightness filter simply adds (or subtracts) a constant value to each pixel’s R, G, and B channels, making the image overall lighter or darker.
Preview
Brightness Filter Preview Usage in Code
Brightness.cs |
---|
| private int Clamp(int value)
{
return Math.Max(0, Math.Min(255, value));
}
private Bitmap ApplyBrightnessFilter(Bitmap sourceImage, int brightness)
{
Bitmap newImage = new Bitmap(sourceImage.Width, sourceImage.Height);
for (int x = 0; x < sourceImage.Width; x++)
{
for (int y = 0; y < sourceImage.Height; y++)
{
Color pixel = sourceImage.GetPixel(x, y);
int r = Clamp(pixel.R + brightness);
int g = Clamp(pixel.G + brightness);
int b = Clamp(pixel.B + brightness);
Color newColor = Color.FromArgb(r, g, b);
newImage.SetPixel(x, y, newColor);
}
}
return newImage;
}
|
Created: 2025-06-28
Updated: 2025-06-28