The Contrast effect can be used to increase or decrease the contrast of an image.

The value given is used to stretch the contrast within the image. Values greater than zero increase the amount of contrast while those less than zero decrease the contrast.

Syntax

[C#]

static void Contrast(Bitmap bitmap, double amount);

[Visual Basic]

Shared Sub Contrast(bitmap As Bitmap, amount As Double)
Params
Name Description
bitmap The bitmap to process
amount Amount to increase or decrease contrast by.
Notes

None.

Example

[C#]using (Bitmap bm = (Bitmap)Bitmap.FromFile(Server.MapPath("rez/andreas-dress-Iw12lY3koDk-unsplash.jpg"))) {
  Effects.Brightness(bm, 20);
  bm.Save(Server.MapPath("IG8_Effects_Brightness1.jpg"));
}
using (Bitmap bm = (Bitmap)Bitmap.FromFile(Server.MapPath("rez/andreas-dress-Iw12lY3koDk-unsplash.jpg"))) {
  Effects.Brightness(bm, -20);
  bm.Save(Server.MapPath("IG8_Effects_Brightness2.jpg"));
}
using (Bitmap bm = (Bitmap)Bitmap.FromFile(Server.MapPath("rez/andreas-dress-Iw12lY3koDk-unsplash.jpg"))) {
  Effects.Brightness(bm, 60);
  bm.Save(Server.MapPath("IG8_Effects_Brightness3.jpg"));
}


Here we apply a brightness effect with different amounts of brightness. Ouput files are shown below.


andreas-dress-Iw12lY3koDk-unsplash.jpg


IG8_Effects_Brightness1.jpg


IG8_Effects_Brightness2.jpg


IG8_Effects_Brightness3.jpg