AdjustContrast

GifImage.AdjustContrast method

Adjusts the contrast of the image, enhancing or reducing the difference in brightness between pixels. This method modifies the image’s overall tonal range, making darker areas darker and brighter areas brighter to improve visual clarity and detail.

public override void AdjustContrast(float contrast)
ParameterTypeDescription
contrastSingleContrast value (in range [-100; 100])

Exceptions

exceptioncondition
ImageExceptionCan’t change contrast. Frame index: " + frameIndex

Examples

The following example performs contrast correction of a GIF image.

[C#]

string dir = "c:\\temp\\";

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
    Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;

    // Set the contrast value. The accepted values of contrast are in the range [-100f, 100f].
    gifImage.AdjustContrast(50f);
    gifImage.Save(dir + "sample.AdjustContrast.png", new Aspose.Imaging.ImageOptions.PngOptions());
}

See Also