Skip to content
ChartForgeX
Class

RasterAnimationEncoder

ChartForgeX.Raster

Namespace
ChartForgeX.Raster
Assembly
ChartForgeX
Modifiers
static

Encodes complete RGBA canvases as GIF or animated PNG using the managed raster engines.

Inheritance

  • object
  • RasterAnimationEncoder

Remarks

Frames must share their dimensions. Both containers preserve zero frame delays. GIF rounds cumulative positive frame boundaries to the nearest 10 milliseconds, with a 10 millisecond minimum and 655.35 second maximum, and treats alpha below 128 as transparent. APNG preserves representable rational durations and otherwise rounds to a supported fraction, with a 65,535 second maximum. Encoder working buffers and returned output share a 256 MiB ceiling; caller-owned input pixel buffers are excluded. The frame list and pixel buffers must remain unchanged while encoding.

Methods

Encode 2 overloads
public static byte[] Encode(IReadOnlyList<RasterAnimationFrame> frames, RasterAnimationFormat format, RasterAnimationOptions? options = null, CancellationToken cancellationToken = default) #

Encodes frames into a new byte array.

Parameters

frames System.Collections.Generic.IReadOnlyList<ChartForgeX.Raster.RasterAnimationFrame> required
One or more complete RGBA frames with matching dimensions.
format ChartForgeX.Raster.RasterAnimationFormat required
The GIF or APNG container.
options ChartForgeX.Raster.RasterAnimationOptions? = null optional
Playback and encoding options; omitted options repeat indefinitely with PNG compression level 6.
cancellationToken System.Threading.CancellationToken = default optional
Cancels validation and encoding between units of work.

Returns

byte[] The encoded animation.
public static byte[] Encode(RasterAnimationSource source, RasterAnimationFormat format, RasterAnimationOptions? options = null, CancellationToken cancellationToken = default) #

Encodes a repeatable producer with memory bounded independently of frame count.

Parameters

source ChartForgeX.Raster.RasterAnimationSource required
format ChartForgeX.Raster.RasterAnimationFormat required
options ChartForgeX.Raster.RasterAnimationOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

byte[]
WriteTo 2 overloads
public static void WriteTo(Stream stream, IReadOnlyList<RasterAnimationFrame> frames, RasterAnimationFormat format, RasterAnimationOptions? options = null, CancellationToken cancellationToken = default) #

Writes an animation to a caller-owned writable stream and leaves that stream open.

Parameters

stream System.IO.Stream required
The destination stream. Validation completes before any bytes are written.
frames System.Collections.Generic.IReadOnlyList<ChartForgeX.Raster.RasterAnimationFrame> required
One or more complete RGBA frames with matching dimensions.
format ChartForgeX.Raster.RasterAnimationFormat required
The GIF or APNG container.
options ChartForgeX.Raster.RasterAnimationOptions? = null optional
Playback and encoding options; omitted options repeat indefinitely with PNG compression level 6.
cancellationToken System.Threading.CancellationToken = default optional
Cancels validation and encoding between units of work.
public static void WriteTo(Stream stream, RasterAnimationSource source, RasterAnimationFormat format, RasterAnimationOptions? options = null, CancellationToken cancellationToken = default) #

Writes a repeatable producer to a caller-owned stream, leaving it open.

Parameters

stream System.IO.Stream required
source ChartForgeX.Raster.RasterAnimationSource required
format ChartForgeX.Raster.RasterAnimationFormat required
options ChartForgeX.Raster.RasterAnimationOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional