Skip to main content

Module image

Module image 

Source
Expand description

Image and image-mask rendering — replaces Splash::fillImageMask, Splash::drawImage, and the four scaleImage* / scaleMask* helpers.

§Scope

Only axis-aligned scaling (matrix[1] == 0 && matrix[2] == 0) with optional vertical flip (negative Y scale) is implemented. Rotated or skewed transforms return ImageResult::ArbitraryTransformSkipped so the caller can fall back to a general path.

§Scaling strategy

Four Bresenham variants mirror the C++ scaleMask* / scaleImage* family:

Y axisX axisMethod
down ↓down ↓Box-filter (average) in both axes
down ↓up ↑Box-filter in Y, nearest-neighbour in X
up ↑down ↓Nearest-neighbour in Y, box-filter in X
up ↑up ↑Nearest-neighbour in both axes

All four variants process source rows exactly once, allocating no extra heap per row. “Down” means scaled < src; “up” means scaled ≥ src.

§Pixel-count contract

draw_image derives the component count directly from P::BYTES, eliminating any possibility of a caller passing a mismatched value.

§C++ equivalents

  • Splash::fillImageMask
  • Splash::drawImage
  • Splash::scaleMask{YdownXdown,YdownXup,YupXdown,YupXup}
  • Splash::scaleImage{YdownXdown,YdownXup,YupXdown,YupXup}
  • Splash::blitMask

Enums§

ImageResult
Return value from fill_image_mask and draw_image.

Traits§

ImageSource
Caller-supplied source for a colour image: one row at a time.
MaskSource
Caller-supplied source for a 1-bit image mask: one row at a time.

Functions§

draw_image
Render a colour image with transformation.
fill_image_mask
Fill a 1-bit image mask using the current fill pattern.