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§
- Held
Images - Encoded pictures by address, shared with the fetcher of every store
Self::storemade.
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::ImageDatafrom an image store or a media reading) as the smalldata:picture a card draws, or another process is handed: aedgesquare 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,widthwide 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 thanHERO_BUDGET. - mosaic
- A 2×2 mosaic of up to four pictures, as a
PORTRAIT_SIDEsquare JPEG: a playlist’s cover from its tracks’ artwork. One picture fills the whole square; two or three repeat to fill the quarters.Nonewhen none decode. - mosaic_
of mosaicfor pictures already decoded (covers an image store loaded): asidesquare of up to four, sampled straight into place, so composing it costs one pass over its pixels.Nonewithout a picture in a format it reads (8-bit RGBA or BGRA).- picture_
bytes - The picture
picture_textwrote (or any standard or MIME-wrapped base64, as vCards carry it), orNonewhen 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 aPORTRAIT_SIDEsquare JPEG, cropped to its centre, orNonewhen it does not decode.