ImageExtensionsToIcon(Image) Method

Creates an Icon from an Image.

Definition

Namespace: KGySoft.Drawing
Assembly: KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 10.1.0
C#
public static Icon ToIcon(
	this Image image
)

Parameters

image  Image
The image to be converted to an icon.

Return Value

Icon
An Icon instance created from the image that has the same size as the specified image.

Usage Note

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

The result icon will have the same size as the specified image. To force creating a squared icon, use the ToIcon(Image, Int32, Boolean) overload instead.

If the raw format of image is an icon that contains multiple images, then the result will also contain multiple resolutions.

To disable PNG compression also for large images regardless of the current operating system use the Combine(Bitmap, Color, Boolean) method instead.

This overload attempts to reduce the color depth of the image losslessly if possible. To prevent that, use the ToIcon(Image, Color) overload instead.

The result Icon is compatible with Windows XP if the method is executed in a Windows XP environment.

See Also