ApngEncoder

public sealed class ApngEncoder : IDisposable
Streaming encoder for Animated PNG (APNG) files. Frames are compressed and written to the output stream the moment they are added, so a complete animation never needs to reside in memory at once.

Constructors

ApngEncoder

#
Create an encoder that writes to an existing stream. The stream must be seekable so the frame count can be back-patched once all frames are known. The caller retains ownership of the stream.
public ApngEncoder(
stream,
Seekable, writable target stream.
loopCount = 0
Number of times the animation plays; 0 loops forever.
)

ApngEncoder

#
Create an encoder that writes to a file on disc.
public ApngEncoder(
path,
Full path of the file to create. Any existing file is overwritten.
loopCount = 0
Number of times the animation plays; 0 loops forever.
)

Properties

FrameCount

#
Gets the number of frames written so far.
public int FrameCount { get; }

Methods

AddFrame

#
Append a frame to the animation. The bitmap is compressed and written immediately, so the caller may dispose it as soon as this method returns. Every frame must share the dimensions of the first frame.
public void AddFrame(
Bitmap
frame,
Frame image. Must be a 32-bits-per-pixel bitmap.
delayMs
Duration this frame stays on screen, in milliseconds (0..65535).
)

Dispose

#
Finish the animation (when it holds at least one frame) and release the underlying stream if this encoder owns it.
public void Dispose()

Encode

#
Convenience helper that encodes a complete array of frames with a single uniform delay. Buffers no more than one frame at a time internally.
public static void Encode(
path,
Full path of the file to create.
Bitmap[]
frames,
Frames to encode; all must share the same dimensions.
delayMs,
Duration each frame stays on screen, in milliseconds.
loopCount = 0
Number of times the animation plays; 0 loops forever.
)

Finish

#
Complete the file: back-patch the frame count, write the terminating chunk and flush the stream. Called automatically by Dispose() if it has not been invoked explicitly.
public void Finish()