Expand description
Making a one-bit picture from a colour one, ahead of time (game ADR-0085). A tool runs it (a build script, a command); never the device.
The picture is first enlarged to the size it is shown at: by
doubling pixels when the scale is a whole number, by a smooth
(bilinear) resample when it isn’t, so rows and columns aren’t doubled
unevenly. Then each Method makes one style of it, at the enlarged
size, so each dot is one screen pixel:
- each pixel’s brightness, optionally through a curve;
- the stretch: the darkest share of the pixels becomes black, the lightest share white, the rest spread between;
- optionally each grey rounded to one of a few levels, so an area is one even pattern;
- a 4 × 4 Bayer ordered dither;
- optionally the art’s own dark lines drawn solid black on top.
A pixel less than half opaque is see-through: clear in the mask, white in every style.
Structs§
- Lines
- Which pixels of the art are its dark lines: an opaque art pixel (before
enlarging) that is
contrastdarker than the brightest of its eight neighbours, or at mostdarkbright. A see-through neighbour counts as white, so a figure’s dark outline is a line; past the picture’s edge there are no neighbours. Brightnesses are 0 to 1, read before the curve. - Method
- How one style of a picture is made (the steps at the top of the module).
- Rgba
- A colour picture: rows of RGBA pixels, 4 bytes each, no padding.
Functions§
- convert
- The one-bit picture file of
imageenlargednum / dentimes (each side rounded to the nearest pixel), one style per method in order, or what is wrong. - png_
pixels - PNG file
bytesas a colour picture: its width, height and RGBA pixels (Rgba::new), whatever kind of PNG it is (palette, grey, with or without alpha, 16 bits a channel).