Skip to main content

Module dither

Module dither 

Source
Expand description

Making a colour picture one-bit at bake time, in integers (ADR-0008 §4): shuyi bake --target playdate makes every picture a one-bit picture file once, so the device never dithers. The same picture and settings give the same file on every platform, so the baked file is tested equal to dithering its source again (ADR-0007 §4).

How a picture is made one-bit is its import settings’ onebit section (OneBitSettings, ADR-0057): images/hero.png.meta holding (onebit: (dither: bayer)) sets one picture, an _folder.meta a folder. The picture keeps its size: one dot a pixel.

Each pixel is first a brightness from 0 (black) to 255 (white), (77 r + 150 g + 29 b + 128) / 256, turned over (255 − b) when the settings say invert; then the Dither makes it black or white. A pixel whose alpha is below alpha_cut is see-through: clear in the mask (the file has one only if some pixel is), white in the picture, and no error spreads to or from it.

Dithered (with the png feature) is the format that reads a PNG as a OneBitPicture this way.

Structs§

Dithered
A PNG made a OneBitPicture by its onebit import settings (dithered, .png, with the png feature): its pixels read as Png reads them, then dithered. A tool registers it; a one-bit device reads the pictures it made with OneBitFile.
OneBitSettings
A picture’s onebit import settings section (ADR-0057): how it is made one-bit. Every field may be left out: (onebit: ()) is the default, Atkinson with a cut at 128.

Enums§

Dither
How a picture’s greys become black and white.

Functions§

brightness
A picture’s brightness from 0 to 255 of the pixel [r, g, b, _].
dither
The one-bit picture file of image made by settings: one style the image’s size, and a mask if a pixel is see-through. Its source size is the image’s own. An error, in plain words, for a picture too big for the file (a side over 65,535 pixels), with no pixels or short of them, or for one with a grey under Dither::None.