AniEncoder Class

Immutable settings for Windows animated cursor (.ani) encoding.

public sealed class AniEncoder : ImageEncoder

Remarks

An animated cursor is an animation whose frames are cursor images: every frame of the image is written as one step, with its duration and its hotspot (FrameMetadata.Hotspot, the top-left corner when the frame has none). A still image is written as an animation of one step.

A step lasts a whole number of jiffies (sixtieths of a second): AniEncoder.DurationRounding decides what happens to a duration that is not one. The format has no play count, an animated cursor always loops: an image whose AnimationMetadata.TotalPlays is not null is rejected with an UnsupportedImageFeatureException, never written as an endless animation silently.

Frames whose encoded cursor image and hotspot are identical are stored once and shown again through the sequence table of the file, so an animation that repeats a drawing does not repeat its bytes. Each frame holds one representation, written like a cursor file: a still PNG or a 32-bit DIB, selected by AniEncoder.PayloadFormat.

The container stores at most 256 pixels per side; a larger image is rejected with an UnsupportedImageFeatureException. The destination must be seekable: frames are written as they arrive, with a memory use independent of their number, and the counts and sizes stored at the start of the file are written once the last frame is known.

Metadata (subject to ImageEncoder.MetadataHandling): one Title and one Author text entry (ImageMetadata.TextEntries) without a language or a translated keyword, whose value is Latin-1 text without a NUL character, are stored. Other text entries, a resolution, an ICC profile, EXIF, XMP and an orientation other than ExifOrientation.TopLeft cannot be stored (rejected by default).

Inheritance
ImageEncoder AniEncoder

Constructors

NameDescription
AniEncoder()

AniEncoder()

AniEncoder.cs
public AniEncoder()

No documentation is available.

Properties

NameDescription
DurationRoundingGets how frame durations are converted to jiffies (sixtieths of a second). Defaults to FrameDurationRounding.RoundToNearest.
FormatGets the format produced by this encoder.
PayloadFormatGets how the pixels of a frame are stored. Defaults to IconPayloadFormat.Auto.

DurationRounding

AniEncoder.cs

Gets how frame durations are converted to jiffies (sixtieths of a second). Defaults to FrameDurationRounding.RoundToNearest.

public FrameDurationRounding DurationRounding { get; init; }

Property value

FrameDurationRounding

Exceptions

ArgumentOutOfRangeException
The value is not a defined FrameDurationRounding.

Gets the format produced by this encoder.

public override ImageFormat Format { get; }

Property value

ImageFormat

PayloadFormat

AniEncoder.cs

Gets how the pixels of a frame are stored. Defaults to IconPayloadFormat.Auto.

public IconPayloadFormat PayloadFormat { get; init; }

Property value

IconPayloadFormat

Exceptions

ArgumentOutOfRangeException
The value is not a defined IconPayloadFormat.

Remarks

IconPayloadFormat.Auto writes a PNG for frames larger than 64 pixels per side and for pixel formats with 16-bit samples, which a DIB cannot store, and a 32-bit DIB otherwise. IconPayloadFormat.Dib with 16-bit samples is rejected with an UnsupportedImageFeatureException: nothing is narrowed silently.

Constants

NameDescription
MaxDimensionThe largest frame an animated cursor can store, per side (256 pixels).

MaxDimension

The largest frame an animated cursor can store, per side (256 pixels).

public const int MaxDimension = 256