Expand description
Raster images (docs/images.md): decoding encoded bytes into a native image, reading what it
is, encoding it back, and releasing it again. Rendering a canvas drawing into a bitmap or a
PDF (docs/canvas.md “Exporting”) lives here too: a rendered bitmap is the same Bitmap a
decode returns, held in the same toolkit table.
The shape mirrors presentation (present.rs): a request id, a pending registry, and a
completion that arrives as an day_spec::Event the backend raises. It is request-shaped rather than
blocking because one backend can never answer synchronously (a browser decodes through
createImageBitmap, which is a promise), and one async-shaped API everywhere beats a
synchronous one that is a lie on the web (docs/async.md rule 3: a callback and a future,
never a runtime).
Everything here is thread-local and !Send, like the rest of day-core: Day has one UI thread.
Structs§
- Bitmap
- A decoded image the toolkit holds, released when the last handle drops.
- Canvas
Exports - What this toolkit can export a canvas drawing to (
Cap::CanvasBitmap,Cap::CanvasPdf). Read it to enable or hide export commands, the wayimage_encode_formatsdecides which formats to offer. - Decode
Future - A decode in flight. Resolves with the decoded
Bitmap, or why it could not be. - Encode
Future - An encode in flight. Resolves with the encoded bytes, or why they could not be produced.
- Render
Bitmap - A bitmap render in flight. Resolves with the rendered
Bitmap, or why it could not be. Nothing is asked of the toolkit until the first poll. - Render
Pdf - A PDF render in flight. Resolves with the document’s bytes, or why they could not be produced. Nothing is asked of the toolkit until the first poll.
Functions§
- canvas_
exports - What this toolkit can export a canvas drawing to.
- decode
- Decode encoded image bytes (PNG/JPEG/…) with the platform’s own decoder.
- decode_
async decode’s callback half (docs/async.md rule 3), for a call site that is not already async.- image_
decode_ support - Whether this toolkit can decode image bytes at all (
Cap::ImageDecode). - image_
encode_ formats - Which formats
Bitmap::encodecan write here: theCap::ImageEncodecounterpart offont_families(). Empty where encoding is unsupported. - image_
encode_ support - Whether this toolkit can encode a decoded image back to bytes (
Cap::ImageEncode). - render_
bitmap - Replay
opsinto an offscreen bitmap ofsizepoints atscalepixels per point, through the toolkit’s own canvas painter. Resolves with aBitmaplike a decode does, soimage(&bitmap),Draw::imageandBitmap::encodeall take it. Apps reach this throughDrawing::to_bitmap. - render_
bitmap_ async render_bitmap’s callback half (docs/async.md rule 3).- render_
pdf - Replay each page into one PDF document through the platform’s own PDF writer. Resolves with
the document’s bytes. Apps reach this through
Drawing::to_pdfandPdfDocument::render. - render_
pdf_ async render_pdf’s callback half (docs/async.md rule 3).- resolve_
bitmap_ render - Deliver a bitmap render’s answer (
Event::BitmapRendered). The same contract asresolve_image_decode, including releasing a success nobody is waiting for. - resolve_
image_ decode - Deliver a decode answer. Called from
pump_events; a request already answered, cancelled, or never issued finds nothing and does nothing, the same contract presentation has. - resolve_
image_ encode - Deliver an encode answer (see
resolve_image_decode). - resolve_
pdf_ render - Deliver a PDF render’s answer (
Event::PdfRendered).