ImageExtensionsToGrayscale Method

Returns a new Image, which is the grayscale version of the specified image.

Definition

Namespace: KGySoft.Drawing
Assembly: KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 8.1.0
C#
public static Image ToGrayscale(
	this Image image
)

Parameters

image  Image
The image to convert to grayscale.

Return Value

Image
An Image containing the grayscale version of the original image.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Image. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

  Note

This method adjusts the degree of parallelization automatically, blocks the caller, and does not support cancellation or reporting progress. Use the BitmapDataExtensions.BeginToGrayscale or ToGrayscaleAsync (in .NET Framework 4.0 and above) methods for asynchronous call and to adjust parallelization, set up cancellation and for reporting progress.

This method always returns a Bitmap with Format32bppArgb pixel format.

To return a Bitmap with arbitrary PixelFormat use the ConvertPixelFormat overloads with a grayscale palette, quantizer (eg. PredefinedColorsQuantizer.Grayscale) or pixel format (Format16bppGrayScale).

To make a Bitmap grayscale without creating a new instance use the BitmapExtensions.MakeGrayscale method.

See Also