ImageExtensionsToIcon(Image, Int32, Boolean) Method

Creates an Icon from an Image.

Definition

Namespace: KGySoft.Drawing
Assembly: KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 8.1.0
C#
public static Icon ToIcon(
	this Image image,
	int size,
	bool keepAspectRatio
)

Parameters

image  Image
The image to be converted to an icon.
size  Int32
The required width and height of the icon.
keepAspectRatio  Boolean
When source image is not square sized, determines whether the image should keep aspect ratio.

Return Value

Icon
An Icon instance created from the 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 be always square sized and will contain only a single image. To create a possibly non-squared icon, use the ToIcon(Image, Color) overload or the Icons.Combine method instead.

See Also