BitmapDataExtensionsGetColorCount Method

Gets the actual number of colors of the specified bitmapData. Colors are counted even for indexed bitmaps.

Definition

Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 8.0.0-preview.1
C#
public static int GetColorCount(
	this IReadableBitmapData bitmapData
)

Parameters

bitmapData  IReadableBitmapData
The bitmap, whose colors have to be counted to count its colors.

Return Value

Int32
The actual number of colors of the specified 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 blocks the caller, and does not support cancellation or reporting progress. Use the BeginGetColorCount or GetColorCountAsync (in .NET Framework 4.0 and above) methods for asynchronous call and to set up cancellation or for reporting progress.

Completely transparent pixels are considered the same regardless of their color information.

Every KnownPixelFormat is supported, but an accurate result is returned for wide color formats only when RowSize is large enough to access all pixels directly (might not be the case for a clipped bitmap data, for example). Otherwise, colors are quantized to 32 bits-per-pixel values while counting them. Wide pixel formats are Format16bppGrayScale, Format48bppRgb, Format64bppArgb and Format64bppPArgb.

See Also