BitmapExtensionsGetColorCount Method

KGy SOFT Drawing Libraries Help
Gets the actual number of colors of the specified bitmap. Colors are counted even for indexed bitmaps.
See the Remarks section for details.

Namespace:  KGySoft.Drawing
Assembly:  KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 5.1.0
Syntax

public static int GetColorCount(
	this Bitmap bitmap
)

Parameters

bitmap
Type: System.DrawingBitmap
The bitmap, whose colors have to be counted to count its colors.

Return Value

Type: Int32
The actual number of colors of the specified bitmap.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Bitmap. 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

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

Every PixelFormat is supported, and an accurate result is returned even for wide color formats (Format16bppGrayScale, Format48bppRgb, Format64bppArgb and Format64bppPArgb).

Note Note
For information about the possible usable PixelFormats on different platforms see the Remarks section of the ConvertPixelFormat method.

See Also

Reference