Skip to content

LayoutRounding.SnapRectEdgesToPixelsOutward method

Snaps a rectangle outward (floor left/top, ceil right/bottom) so it never shrinks.

public static Rect SnapRectEdgesToPixelsOutward(Rect rect, double dpiScale)

A small epsilon tolerance prevents floating-point round-trip errors (e.g. Floor((16/1.5 + 2/1.5) * 1.5) yielding 17 instead of 18) from shifting edges by an extra device pixel.