PeachDrawing

PeachDrawing.Filters

FilterOps Class

The pixel operations behind the SVG filter primitives that PDF cannot express, on premultiplied RGBA8 surfaces of one size. Each takes its inputs and writes a result of the same size; none keeps state. Geometry-dependent parameters (radii, offsets, scales) arrive already converted to pixels.

public static class FilterOps

Inheritance System.Object → FilterOps

Methods  
Arithmetic(RasterSurface, RasterSurface, RasterSurface, double, double, double, double) k1*i1*i2 + k2*i1 + k3*i2 + k4 on premultiplied 0-1 channels, clamped, with colour kept within alpha.
Blank(RasterSurface) A transparent surface on the same grid as like.
Blend(PaintBlendMode, RasterSurface, RasterSurface, RasterSurface) Composites top over bottom with a blend mode, into result.
ClipTo(RasterSurface, IntRect) Makes every pixel outside keep transparent.
Clone(RasterSurface) A copy of source on the same grid.
ComponentTransfer(RasterSurface, RasterSurface, byte[], byte[], byte[], byte[]) Applies four per-channel lookup tables (R, G, B, A) to the straight colour of every pixel.
ConvertColor(PaintColor, bool) Converts a colour from sRGB to linear light (or back) - straight colour, so the surface is unpremultiplied, mapped and premultiplied again.
ConvertColorSpace(RasterSurface, bool) Re-encodes surface from sRGB to linear light, or from linear light to sRGB, in place.
CopyCentre(RasterSurface, RasterSurface, int, int) Copies the middle of padded (inside a border of padX x padY pixels) into destination.
Displace(RasterSurface, RasterSurface, RasterSurface, double, double, int, int) Each output pixel takes the input pixel displaced by the map’s channels: P'(x, y) = P(x + sx * (XC - 0.5), y + sy * (YC - 0.5)), nearest pixel, transparent outside.
Fill(RasterSurface, PaintColor, double) Sets every pixel to color at opacity (premultiplied on the way in).
MirrorPad(RasterSurface, int, int) A surface padX x padY pixels larger on every side than source, on the same grid, whose border is source reflected across its edges (edge mode “mirror”).
Morphology(RasterSurface, RasterSurface, int, int, bool) Erodes (per-channel minimum) or dilates (maximum) with a (2rx+1) x (2ry+1) window; what lies outside the surface counts as transparent.
Offset(RasterSurface, RasterSurface, int, int) Copies source shifted by (dx, dy) whole pixels; what moves in from outside is transparent.
OverInPlace(RasterSurface, RasterSurface) Draws top over destination in place (source-over).
PorterDuff(string, RasterSurface, RasterSurface, RasterSurface) Porter-Duff over, in, out, atop or xor of a (the in input) with b (in2).
Tile(RasterSurface, RasterSurface, IntRect) Repeats the tile rectangle of source across the whole of destination.
ZeroColor(RasterSurface) Clears the colour of every pixel and keeps its alpha - a premultiplied pixel of alpha a and no colour is opaque black at that coverage, which is what SourceAlpha and BackgroundAlpha are.