BitmapDataExtensionsToGrayscale Method

Returns a new IReadWriteBitmapData, which is the grayscale version of the specified bitmapData.

Definition

Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 7.0.0
C#
public static IReadWriteBitmapData ToGrayscale(
	this IReadableBitmapData bitmapData
)

Parameters

bitmapData  IReadableBitmapData
The IReadableBitmapData to convert to grayscale.

Return Value

IReadWriteBitmapData
An IReadWriteBitmapData containing the grayscale version of the original bitmapData.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IReadableBitmapData. 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 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 new IReadWriteBitmapData with Format32bppArgb pixel format.

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

To make an IReadWriteBitmapData grayscale without creating a new instance use the MakeGrayscale method.

See Also