IconExtensionsResize(Icon, Size) Method

Resizes an Icon to the specified size.

Definition

Namespace: KGySoft.Drawing
Assembly: KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 10.1.0
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. It provides a good quality result on Windows, but it also blocks every parallel DrawImage call within the same process. On non-Windows platforms (e.g. when the operation is backed by libgdiplus) the quality of the result can be quite poor. If these can be issues, use the Resize(Icon, Size, ScalingMode) overload instead.

See Also