PeachDrawing

PeachDrawing

RasterSurfaceEncoding Class

Encodes a finished RasterSurface’s pixels into bytes a PDF (or any other) embedder can wrap - the “pixels in, encoded bytes out” half of embedding a raster surface in a document. Deliberately has no PDF library dependency: the document-specific wrapping is left to the embedder.

public static class RasterSurfaceEncoding

Inheritance System.Object → RasterSurfaceEncoding

Methods  
EncodePng(RasterSurface, bool) Encodes surface as a lossless PNG (byte-for-byte IDAT the PDF writer’s existing PNG pass-through can embed directly, with a split-out alpha plane when there is alpha). A fully opaque surface is encoded without an alpha channel.
IsOpaque(RasterSurface) Whether every pixel of surface is fully opaque, so it needs no alpha plane (and no soft mask) to embed.
Save(RasterSurface, Stream, string, EncoderOptions) Encodes surface’s pixels (unpremultiplied first, since every PeachImage format expects straight alpha) into stream in any format PeachImage supports, for a standalone RasterCanvas canvas’s own Save. A fully opaque surface is encoded without an alpha channel, the same as EncodePng(RasterSurface, bool).
SaveAsync(RasterSurface, Stream, string, EncoderOptions, CancellationToken) Encodes surface’s pixels (unpremultiplied first, since every PeachImage format expects straight alpha) into stream in any format PeachImage supports, for a standalone RasterCanvas canvas’s own Save. A fully opaque surface is encoded without an alpha channel, the same as EncodePng(RasterSurface, bool).
ToCmykPixels(RasterSurface, bool) Converts surface’s (necessarily opaque) RGB pixels to raw CMYK bytes by naive subtractive conversion, for the PDF/X-1a raw-DeviceCMYK embedding path (PDF/X-1a forbids RGB).