IconExtensionsResize(Icon, Size) Method

Resizes an Icon to the specified size.

Definition

Namespace: KGySoft.Drawing
Assembly: KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 10.0.0-rc.1
C#
public static Icon Resize(
	this Icon icon,
	Size size
)

Parameters

icon  Icon
The icon to resize.
size  Size
The required size of the result.

Return Value

Icon
An Icon instance that contains exactly one image with the specified size.

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 the icon contains images with the specified size, then this method just extracts the highest bit-per-pixel image of the requested size.

If the icon does not contain an image exactly with the specified size, then this method takes a close image in size and resizes that to the requested size. If resizing happens, the result will always contain a 32 bpp image.

If an actual resize is needed, this overload uses Graphics.DrawImage internally, which provides a good quality result but on Windows blocks every parallel DrawImage call within the same process. If that might be an issue use the Resize(Icon, Size, ScalingMode) overload instead.

See Also