# ApngEncoder class

Namespace: [Grasshopper2.Imaging](https://developer.rhino3d.com/api/gh2/namespace/grasshopper2.imaging.md) · Assembly: [Grasshopper2](https://developer.rhino3d.com/api/gh2/assembly/grasshopper2.md)

```cs
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](https://developer.rhino3d.com/api/gh2/type/grasshopper2.imaging.apngencoder/ctor.md): (2 overloads) 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.

## Properties

- [FrameCount](https://developer.rhino3d.com/api/gh2/type/grasshopper2.imaging.apngencoder/framecount.md): Gets the number of frames written so far.

## Methods

- [AddFrame](https://developer.rhino3d.com/api/gh2/type/grasshopper2.imaging.apngencoder/addframe.md): 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.
- [Dispose](https://developer.rhino3d.com/api/gh2/type/grasshopper2.imaging.apngencoder/dispose.md): Finish the animation (when it holds at least one frame) and release the underlying stream if this encoder owns it.
- [Encode](https://developer.rhino3d.com/api/gh2/type/grasshopper2.imaging.apngencoder/encode.md): (static) Convenience helper that encodes a complete array of frames with a single uniform delay. Buffers no more than one frame at a time internally.
- [Finish](https://developer.rhino3d.com/api/gh2/type/grasshopper2.imaging.apngencoder/finish.md): Complete the file: back-patch the frame count, write the terminating chunk and flush the stream. Called automatically by [ApngEncoder.Dispose()](https://developer.rhino3d.com/api/gh2/type/grasshopper2.imaging.apngencoder/dispose.md) if it has not been invoked explicitly.
