Expand description
The image table: every PNG in a Bundle the game names, by bundle
path, with its size. Screens name a picture by an ImageId from this
table; the platform layer decodes and draws it. Only each file’s header
is read here, never its pixels.
A one-bit screen’s bundle may hold a one-bit picture file
(crate::bitmap) at a PNG’s path in place of the PNG: the table
then gives the size of the PNG it was made from (its source size), so
the image’s id and size are the same as with the PNG.
As formats (ADR-0007): an image’s size is the ImageInfo kind, read
by PngInfo and OneBitInfo, and
ImageTable::load_with builds the table with every image format a
game registers. Its pixels are the Image kind, which Png reads
with the png feature. A game that draws through shuyi-app needs
none: the platform decodes a PNG’s pixels when it uploads the picture.
Structs§
- Image
- An image’s pixels: four bytes each (red, green, blue, alpha), row by row from the top.
- ImageId
- Names one image of an
ImageTable: its interned bundle path. Cheap to copy and compare. OnlyImageTable::idmakes one, so an id always names an image some table holds. - Image
Info - An image’s size in pixels. Build it with
ImageInfo::neworImageInfo::checked(ADR-0039). - Image
Rect - A rectangle of an image, in image pixels.
- Image
Table - Every image the game can draw, by bundle path (
/-separated). Build it withImageTable::new,DefaultorImageTable::load(ADR-0039). - Picture
- A picture: a rectangle of an image.
- Png
- PNG read for its pixels (
png,.png), with thepngfeature. Its size is checked first, asPngInfodoes, so a picture too big is refused before its pixels are decoded. - PngInfo
- PNG read for its size (
png,.png): only its header, never its pixels. The size must be oneImageInfo::checkedallows.
Constants§
- MAX_
PNG_ BYTES - The most bytes a PNG may have: 64 MiB, what a
MAX_SIDEsquare of 8-bit RGBA pixels takes without compression. - MAX_
SIDE - The longest side an image may have, in pixels: what every graphics card the engine runs on (WebGL included) takes as one texture.
- PNG_
SIGNATURE - The first eight bytes of every PNG file.
Functions§
- png_
size - Width and height from a PNG’s header, or
Noneifbytesisn’t a PNG.