PeachDrawing.Core

PeachDrawing.Core

PixelMath Class

Integer pixel arithmetic shared by every raster consumer of PixelBuffer and RasterSurface.

public static class PixelMath

Inheritance System.Object → PixelMath

Methods  
Div255(int) x / 255, rounded to nearest: the exact result for every product of two 8-bit values (0..65025), without a division. This is how a channel is scaled by an alpha or coverage byte.
Premultiply(Span<byte>) Premultiplies straight-alpha RGBA8 in place: each colour channel is scaled by the pixel’s alpha.
Unpremultiply(ReadOnlySpan<byte>, Span<byte>) Converts premultiplied RGBA8 to straight alpha into destination (same length).