ImageExtensionsToIcon(Image, Int32, ScalingMode, 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,
	ScalingMode scalingMode,
	bool keepAspectRatio = true
)

Parameters

image  Image
The image to be converted to an icon.
size  Int32
The required width and height of the icon.
scalingMode  ScalingMode
Specifies the scaling mode if size differs from the original size.
keepAspectRatio  Boolean  (Optional)
When source image is not square sized, determines whether the image should keep aspect ratio. This parameter is optional.
Default value: .

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