Table of Contents

Enum PngFilterMode

Namespace
Egami.Formats.Png
Assembly
Egami.dll

How the PNG writer filters scanlines before compression (PNG specification, section 12.7).

public enum PngFilterMode

Fields

Adaptive = 0

For each row, try all five filters and keep the one with the smallest sum of absolute values, as the specification recommends. Palette images and bit depths below 8 use no filter.

Average = 4

Difference from the average of left and above.

None = 1

No filter.

Paeth = 5

Difference from the Paeth predictor of left, above and upper-left.

Sub = 2

Difference from the pixel to the left.

Up = 3

Difference from the pixel above.

Examples

// Force a palette, choose a filter and a zlib strategy, and keep a private chunk.
((PngDetails)image.Metadata.FormatDetails!).OtherChunks.Add(
    new PngChunk("prVt", "hello"u8.ToArray(), PngChunkPosition.AfterImageData));
image.Save("duck-palette.png", new PngWriterOptions
{
    ColorType = PngColorType.Palette,
    Filter = PngFilterMode.Paeth,
    CompressionStrategy = PngCompressionStrategy.Filtered,
});