Image image = Image.FromFile("image.jpg"); ImageAttributes attributes = new ImageAttributes(); attributes.SetColorMatrix(new ColorMatrix(new float[][]{ new float[]{1, 0, 0, 0, 0}, new float[]{0, 1, 0, 0, 0}, new float[]{0, 0, 1, 0, 0}, new float[]{0, 0, 0, 1, 0}, new float[]{0.2f, 0.2f, 0.2f, 0, 1} })); 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); graphics.Dispose(); image.Save("image_brightness.jpg", ImageFormat.Jpeg);
Image image = Image.FromFile("image.jpg"); ImageAttributes attributes = new ImageAttributes(); attributes.SetColorMatrix(new ColorMatrix(new float[][]{ new float[]{0.5f, 0, 0, 0, 0}, new float[]{0, 0.5f, 0, 0, 0}, new float[]{0, 0, 0.5f, 0, 0}, new float[]{0, 0, 0, 1, 0}, new float[]{0, 0, 0, 0, 1} })); 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); graphics.Dispose(); image.Save("image_color.jpg", ImageFormat.Jpeg);These code examples are using the System.Drawing.Imaging namespace, which is a part of the .NET Framework.