Table of Contents

Class IcoWriterOptions

Namespace
Egami.Formats.Ico
Assembly
Egami.dll

Options for writing ICO and CUR. Each raster becomes one entry at its own size, or one entry per size in Sizes; entries are 8-bit RGBA, sorted smallest first. EXIF, XMP and IPTC are not written; an ICC profile goes into PNG entries.

public sealed class IcoWriterOptions : WriterOptions
Inheritance
IcoWriterOptions
Inherited Members

Examples

// A favicon: 16, 32 and 48 resized from one raster. A raster that is not square is centred on transparency.
logo.Save("favicon.ico", new IcoWriterOptions { Sizes = IcoWriterOptions.FaviconSizes });

// Windows' set: 16 to 256, the 256 entry as PNG and the rest as 32-bit BMP, as Microsoft's guidance asks.
logo.Save("app.ico", new IcoWriterOptions { Sizes = IcoWriterOptions.WindowsSizes, Filter = Egami.Operations.ResampleFilter.Lanczos3 });

// Hand-drawn small sizes: each raster is written at its own size; the 48 comes from the largest raster.
using Raster<Rgba8> drawn16 = logo.Derive(ops => ops.Fit(16, 16));
Raster.SaveAll([logo, drawn16], "drawn.ico", new IcoWriterOptions { Sizes = [16, 48] });

Properties

Default

Gets the default options.

public static IcoWriterOptions Default { get; }

Property Value

IcoWriterOptions

Encoding

Gets how every entry is stored, or null (the default) to choose per entry: PNG for 256 × 256 entries and 32-bit BMP with an AND mask below, as Microsoft's icon guidance asks; an entry written at the size of a raster loaded from an icon keeps that entry's encoding.

public IcoEntryEncoding? Encoding { get; init; }

Property Value

IcoEntryEncoding?

FaviconSizes

Gets the sizes of a favicon: 16, 32 and 48.

public static IReadOnlyList<int> FaviconSizes { get; }

Property Value

IReadOnlyList<int>

Filter

Gets the filter that resizes rasters to Sizes, as for Resize. Defaults to Bicubic.

public ResampleFilter Filter { get; init; }

Property Value

ResampleFilter

Hotspot

Gets a cursor's hotspot at the raster's own size, scaled to each entry and kept inside it, or null (the default) for the raster's Hotspot, else the top-left pixel. Icons ignore it.

public Point? Hotspot { get; init; }

Property Value

Point?

Sizes

Gets the square sizes to write, 1 to 256, or null (the default) to write each raster at its own size, a raster larger than 256 fitted down to 256 with a warning. Each size comes from a raster of exactly that size when one is given, otherwise from the largest raster resized with Filter; a raster that is not square is fitted inside the square and centred on transparency.

public IReadOnlyList<int>? Sizes { get; init; }

Property Value

IReadOnlyList<int>

Exceptions

ArgumentOutOfRangeException

A size is outside 1 to 256.

ArgumentException

The list is empty or names a size twice.

WindowsSizes

Gets the sizes Windows' icon guidance asks for: 16, 24, 32, 48, 64 and 256.

public static IReadOnlyList<int> WindowsSizes { get; }

Property Value

IReadOnlyList<int>