IconExtensionsToAlphaBitmap Method

KGy SOFT Drawing Libraries Help
Converts the specified icon to a Bitmap. While Icon.ToBitmap may return a wrong result when icon contains semi-transparent pixels, this method returns an image, in which alpha channel is always correctly applied for the image.

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

public static Bitmap ToAlphaBitmap(
	this Icon icon
)

Parameters

icon
Type: System.DrawingIcon
The icon optionally with transparency.

Return Value

Type: Bitmap
A Bitmap that represents the converted Icon.

Usage Note

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

If icon is not from a native handle, then this method calls the ExtractBitmap method using the icon size and Format32bppArgb pixel format as parameters.

If the icon contains multiple images consider to use either the ExtractBitmap or ExtractNearestBitmap methods to specify the exact image to return, or the ToMultiResBitmap methods, which return every images in a single combined Bitmap.

See Also

Reference