Skip to main content

Module held_images

Module held_images 

Expand description

Pictures an app already holds as data: a contact’s photo, artwork a media file embeds. They load like any other image (decoded off the UI thread by an ImageStore, cached, a placeholder painted until then), but nothing is fetched: the store’s fetcher reads the bytes the app registered with HeldImages::hold, and an address no one holds fails.

portrait turns any picture a person or a file supplies into the small square JPEG the toolkit keeps for avatars and covers.

Structs§

HeldImages
Encoded pictures by address, shared with the fetcher of every store Self::store made.

Constants§

HERO_BUDGET
The most a hero picture’s encoded bytes may cost: the card shows it at nine sixteenths of its width, so it is worth more bytes than a cover, and it goes to a session’s own floating layer rather than a shared board.
PICTURE_BUDGET
The most a cover’s encoded bytes may cost: a live activity carries the picture beside the song under a wire bound, and a base64 data: picture takes four thirds of that room.
PORTRAIT_SIDE
The side, in pixels, of a portrait: sharp at the largest avatar and cover sizes on a 2× display, small enough to carry in a record.

Functions§

cover
A cover already decoded (crate::peniko::ImageData from an image store or a media reading) as the small data: picture a card draws, or another process is handed: a edge square cut from its centre, JPEG-encoded so it costs a few kilobytes rather than a cover’s own tens. Empty for a picture that is not straight 8-bit RGBA or that does not encode.
hero
A whole picture as the data: picture a card heads itself with, width wide and as tall as the picture’s own shape: no ground around it, so what it caught fills the card. Empty for a picture that does not encode or whose smallest encoding costs more than HERO_BUDGET.
mosaic
A 2×2 mosaic of up to four pictures, as a PORTRAIT_SIDE square JPEG: a playlist’s cover from its tracks’ artwork. One picture fills the whole square; two or three repeat to fill the quarters. None when none decode.
mosaic_of
mosaic for pictures already decoded (covers an image store loaded): a side square of up to four, sampled straight into place, so composing it costs one pass over its pixels. None without a picture in a format it reads (8-bit RGBA or BGRA).
picture_bytes
The picture picture_text wrote (or any standard or MIME-wrapped base64, as vCards carry it), or None when it is not base64.
picture_text
A picture as text, for a record field or a card: standard base64.
portrait
encoded (any format the toolkit decodes) as a PORTRAIT_SIDE square JPEG, cropped to its centre, or None when it does not decode.