imageSampling

fun imageSampling(width: Int, height: Int, ctm: KiteMatrix, interpolate: Boolean): KiteImageSampling

The sampling for an image of width by height pixels drawn under ctm, which maps the image's unit square to device pixels. The rules follow MuPDF:

  • A direction in which the image has at least twice as many pixels as it covers is averaged down by a power of two, to no fewer pixels than it covers. Thin strokes in a scanned page then fade instead of dropping out. MuPDF averages both directions by one factor. Here each direction has its own factor.

  • An image drawn smaller than its pixels in both directions is smoothed.

  • Otherwise, an image enlarged more than twice in either direction keeps hard pixel edges, unless interpolate is true: the /Interpolate entry of ISO 32000-1, Table 89.

  • Otherwise, an image that is rotated, skewed or enlarged is smoothed, and an image drawn at its own size takes the nearest pixel.