Skip to main content

Module images

Module images 

Source
Expand description

Image sizing, and the contour a sheet asks to be traced.

Layout needs one thing from an image — how big it is — and getting it by decoding would put a pixel buffer in the layout pass. So the engine reads the header: PNG’s IHDR and pHYs, JPEG’s SOFn and JFIF density, GIF’s screen descriptor, WebP’s chunk headers. The file is kept as it arrived, and a painter is what decodes it.

A url reaches the table from two places. The content tree names one for every image the manuscript places, and the style tree names one for every box the sheet puts art behind, so probing takes both.

One thing else decodes it: shape-outside: auto, which sets prose around the shape of an image rather than around its box. That is not reachable from where probing happens, because probing has not seen the style tree, so it is a stage of its own. Contours is what that stage keeps: it walks the cascade for the nodes that ask for a traced contour, and traces each asset once.

The engine opens nothing itself, the same as with fonts. Whatever string the content tree writes is the name an image is matched under. It never has to be a real URL; the host is what turns a name into bytes.

Structs§

Asset
One image the book refers to, sized from its header.
Assets
Every image one book refers to, probed once and indexed.
Contour
The outline prose sets around, in the image’s own box.
Contours
Every contour a book’s sheet asked for, traced once and kept by asset.
Intrinsic
An image’s own idea of its size: pixels, and the resolution they are meant to be shown at.
NoImages
A loader that resolves nothing.

Enums§

Added
What registering an image did.

Constants§

CSS_DPI
What CSS calls one pixel: 1/96th of an inch. An image whose header declares no resolution is measured at this one.

Traits§

ImageLoader
Resolves image urls to bytes.

Functions§

backgrounds
Every image a book’s sheet puts behind a box: one per block style and one per page master, in a stable order.
probe
Reads an image’s size from its header. None for a format no probe recognises, or a header too short to read one from.
trace
Traces one image’s alpha channel. None where the format carries no alpha, where the file does not decode, or where it is larger than the tracer decodes.