IconExtensionsToAlphaBitmap Method

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.

Definition

Namespace: KGySoft.Drawing
Assembly: KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 7.1.0
C#
public static Bitmap ToAlphaBitmap(
	this Icon icon
)

Parameters

icon  Icon
The icon optionally with transparency.

Return Value

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