BitmapDataExtensionsGetColorCount Method
Gets the actual number of colors of the specified bitmapData. Colors are counted even for indexed bitmaps.
Namespace: KGySoft.Drawing.ImagingAssembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 9.0.0
public static int GetColorCount(
this IReadableBitmapData bitmapData
)
<ExtensionAttribute>
Public Shared Function GetColorCount (
bitmapData As IReadableBitmapData
) As Integer
public:
[ExtensionAttribute]
static int GetColorCount(
IReadableBitmapData^ bitmapData
)
[<ExtensionAttribute>]
static member GetColorCount :
bitmapData : IReadableBitmapData -> int
- bitmapData IReadableBitmapData
- The bitmap, whose colors have to be counted to count its colors.
Int32The actual number of colors of the specified
bitmapData.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).
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.