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.1.0
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, and an accurate result can be retrieved even for custom pixel formats with wide color formats if color access preference id correctly set in their PixelFormatInfo. Otherwise, colors might be quantized to 32 bits-per-pixel values while counting them.

See Also