ImageExtensionsSaveAsIcon(IEnumerableImage, Stream, Boolean) Method

Saves the specified images as an Icon without relying on a built-in encoder in the operating system. Unlike the Save(Stream, ImageFormat) method, this one supports every PixelFormat and does not save a PNG stream when no built-in Icon encoder can be found in the operating system.

Definition

Namespace: KGySoft.Drawing
Assembly: KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 8.1.0
C#
public static void SaveAsIcon(
	this IEnumerable<Image> images,
	Stream stream,
	bool forceUncompressedResult = false
)

Parameters

images  IEnumerableImage
The images to save as a single icon.
stream  Stream
The stream to save the images into.
forceUncompressedResult  Boolean  (Optional)
to force saving an uncompressed icon; to allow PNG compression, which is supported by Windows Vista and above. This parameter is optional.
Default value: .

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerableImage. 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 icon can be saved even without a registered Icon encoder in the current operating system.

If the saved image is reloaded by the Bitmap(Stream) constructor, then it will have always Format32bppArgb pixel format. The indexed and 24 BPP pixel formats are preserved though if the saved stream is reloaded by the Icon(Stream) constructor.

Exceptions

ArgumentNullExceptionimages or stream is .
ArgumentExceptionimages contains a element.

See Also