RasterAnimationEncoder
ChartForgeX.Raster
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
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>
- One or more complete RGBA frames with matching dimensions.
- format ChartForgeX.Raster.RasterAnimationFormat
- The GIF or APNG container.
- options ChartForgeX.Raster.RasterAnimationOptions? = null
- Playback and encoding options; omitted options repeat indefinitely with PNG compression level 6.
- cancellationToken System.Threading.CancellationToken = default
- 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
- format ChartForgeX.Raster.RasterAnimationFormat
- options ChartForgeX.Raster.RasterAnimationOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
byte[]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
- The destination stream. Validation completes before any bytes are written.
- frames System.Collections.Generic.IReadOnlyList<ChartForgeX.Raster.RasterAnimationFrame>
- One or more complete RGBA frames with matching dimensions.
- format ChartForgeX.Raster.RasterAnimationFormat
- The GIF or APNG container.
- options ChartForgeX.Raster.RasterAnimationOptions? = null
- Playback and encoding options; omitted options repeat indefinitely with PNG compression level 6.
- cancellationToken System.Threading.CancellationToken = default
- 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
- source ChartForgeX.Raster.RasterAnimationSource
- format ChartForgeX.Raster.RasterAnimationFormat
- options ChartForgeX.Raster.RasterAnimationOptions? = null
- cancellationToken System.Threading.CancellationToken = default