Bitmap image = new Bitmap("image.jpg"); for (int x = 0; x < image.Width; x++) { for (int y = 0; y < image.Height; y++) { Color pixelColor = image.GetPixel(x, y); int newBrightness = pixelColor.Brightness + 50; // Increase brightness by 50 Color newColor = Color.FromArgb(pixelColor.R, pixelColor.G, newBrightness); image.SetPixel(x, y, newColor); } } image.Save("modified_image.jpg");
Bitmap image = new Bitmap("image.jpg"); float saturation = 0.5f; // Decrease saturation by 50% ColorMatrix colorMatrix = new ColorMatrix( new float[][]{ new float[] {1 + saturation, 0, 0, 0, 0}, new float[] {0, 1 + saturation, 0, 0, 0}, new float[] {0, 0, 1 + saturation, 0, 0}, new float[] {0, 0, 0, 1, 0}, new float[] {0, 0, 0, 0, 1} }); ImageAttributes attributes = new ImageAttributes(); attributes.SetColorMatrix(colorMatrix); Graphics graphics = Graphics.FromImage(image); graphics.DrawImage(image, new Rectangle(0, 0, image.Width, image.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, attributes); image.Save("modified_image.jpg");Package/Library: System.Drawing.Imaging Overall, the package/library used for these effects is System.Drawing, which provides classes for working with images and graphical effects. Within this package, different namespaces and classes are used depending on the technique used to apply the effect (e.g. pixel manipulation, color matrix).