tawasuyu

tawasuyu/llimphi

Sovereign retained-mode GPU UI framework in Rust (wgpu+vello+taffy+parley), Elm loop, 40+ widgets.

Rust 660Markdown 302TOML 157RON 312382 Sutichaykuna

⎇ main llimphi-image/README.md Markdown · 39 siq'ikuna · 1.5 KB Ñawpa willay ch'uya

chore: refresco desde el monorepo — 27 crates nuevos (anim, lottie, svg, mesh, image, layer, test, wire-view, widgets rag-sidebar/router/lazy-list/rive-button) y sync de los 95 existentes 93253cc22 · Sergio ·

1# llimphi-image
2
3Decode pipeline for `peniko::Image`.
4
5Today a caller wanting to show an image with `View::image()` writes:
6
7```ignore
8let reader = ImageReader::open(path)?.with_guessed_format()?;
9let img = reader.decode()?;
10let rgba = img.to_rgba8();
11let (w, h) = (rgba.width(), rgba.height());
12let blob = Blob::from(rgba.into_raw());
13let pen = Image::new(blob, ImageFormat::Rgba8, w, h);
14```
15
16Five lines plus two `?` per caller (the nahual viewer, the mirada wallpaper, the
17gallery viewer, and so on). This crate encapsulates them in two helpers:
18
19- `decode_bytes` — takes `&[u8]` and returns `Result<peniko::Image>`.
20- `load_path` — takes a `&Path` plus a `max_bytes` cap and returns
21  `Result<peniko::Image>`, with an on-disk size guard (apps do not want to read a
22  4 GB `.iso` thinking it is an image).
23
24With the `net` feature (opt-in, synchronous ureq) it adds download plus per-URL
25caching: `fetch_bytes`/`load_url` (blocking, to run in a worker) and `ImageCache`
26(`Clone + Send + Sync`) that the `view` consults on the UI thread while a
27`Handle::spawn` populates it. The base crate keeps no network dependency.
28
29The `image` (from the `image` crate) is always built with `to_rgba8` — the
30conversion `peniko::ImageFormat::Rgba8` requires. For an image already in
31`rgba8` in memory (no decoding needed) see `from_rgba8`.
32
33Formats: whatever the upstream `image` crate's features enable (in this
34workspace, today: PNG, JPEG, WEBP). Others can be turned on by adding the
35feature; the helper does not limit them.
36
37---
38
39Part of **llimphi** — see [llimphi](../README.md).

README.md

llimphi-image

Decode pipeline for peniko::Image.

Today a caller wanting to show an image with View::image() writes:

let reader = ImageReader::open(path)?.with_guessed_format()?;
let img = reader.decode()?;
let rgba = img.to_rgba8();
let (w, h) = (rgba.width(), rgba.height());
let blob = Blob::from(rgba.into_raw());
let pen = Image::new(blob, ImageFormat::Rgba8, w, h);

Five lines plus two ? per caller (the nahual viewer, the mirada wallpaper, the gallery viewer, and so on). This crate encapsulates them in two helpers:

With the net feature (opt-in, synchronous ureq) it adds download plus per-URL caching: fetch_bytes/load_url (blocking, to run in a worker) and ImageCache (Clone + Send + Sync) that the view consults on the UI thread while a Handle::spawn populates it. The base crate keeps no network dependency.

The image (from the image crate) is always built with to_rgba8 — the conversion peniko::ImageFormat::Rgba8 requires. For an image already in rgba8 in memory (no decoding needed) see from_rgba8.

Formats: whatever the upstream image crate's features enable (in this workspace, today: PNG, JPEG, WEBP). Others can be turned on by adding the feature; the helper does not limit them.


Part of llimphi — see llimphi.