Expand description
Tip bitmaps for every brush file this workspace reads.
preview_abr, preview_brush and preview_brushset each take the whole
file as bytes and return one PreviewEntry per brush in file order,
available or not. A brush whose tip cannot be rendered is reported with a
reason rather than dropped, so a caller can lay out a complete grid. Each
has a _first_available twin that returns only the first n available
entries and builds no entry after them.
preview is the function all six call. It also takes a keep_going
callback that can stop the call between entries, for a host that shows
previews under a time limit.
The available tips of one call hold at most MAX_PREVIEW_BYTES of bitmap
data together. Entries past that point are
UnavailableReason::OverBudget and their tips are not decoded.
Every function here is pure over &[u8]: no filesystem, no threads, so the
crate builds for wasm32-unknown-unknown.
Modules§
- procreate
- Reading Procreate
.brushand.brushsetarchives: the guarded zip and plist readers, theShape.pngdecoder and the two name/member lookups the preview API needs.
Structs§
- Contact
Sheet Config - Grayscale
Bitmap - Preview
Entry - Preview
Error - Preview
Options - Preview
Set - Sheet
Brush - Source
Dimensions - File-declared raster dimensions, independent of the returned preview size. A readable header does not guarantee valid pixels or a safe allocation size.
Enums§
- Format
- The kind of brush file
previewreads. - Sheet
Background - Take
- Which entries a
previewreturns. - TipImage
Error - TipPreview
- Unavailable
Reason
Constants§
- MAX_
IMPORT_ DECODED_ BYTES - The decode budget of
decode_tip_image.TipImageError::TooLargelists what it reserves. - MAX_
IMPORT_ DIMENSION - MAX_
PREVIEW_ BYTES - The most bytes of bitmap data (
GrayscaleBitmap::data) theAvailabletips of onepreviewcall, or one call of a function built on it, hold together.
Functions§
- can_
synthesize - decode_
tip_ image - Decode an imported brush-tip image (PNG/JPEG bytes) into a grayscale tip buffer. Alpha becomes intensity when the image has an alpha channel; otherwise luminance is inverted (dark = opaque), matching Photoshop’s convention.
- downsample
- Box-filter
bitmapso its larger side is at mostmax_side(>= 1). Returns a clone when it already fits. Average of the covered source pixels per destination pixel, the same filtergenerate_preview_pnguses. - generate_
contact_ sheet_ png - generate_
preview_ png - A 200 px RGBA thumbnail: black ink, alpha from the tip’s gray value.
- preview
- Tips for a brush file of
format, astakeselects them. - preview_
abr - Tips for a Photoshop
.abrpack. - preview_
abr_ first_ available - The first
nentries ofpreview_abrwhose tip is available, in the same order and with the sameindexthey have there, so indices may skip. Unavailable entries do not count towardn, and entries after thenth available one or after the firstOverBudgetone are not built, so their tips are not decoded or downsampled. - preview_
brush - The tip of a single Procreate
.brush: one entry at index 0, read from the archive’s root rather than from a member directory. - preview_
brush_ first_ available preview_brushlimited to available tips: its single entry when the tip is available andn >= 1, otherwise no entries. Withn == 0the tip is not decoded.- preview_
brushset - Tips for a Procreate
.brushset. - preview_
brushset_ first_ available - The first
nentries ofpreview_brushsetwhose tip is available, in the same order and with the sameindexthey have there, so indices may skip. Unavailable entries do not count towardn, and members after thenth available one or after the firstOverBudgetone are not read. - synthesize_
computed_ tip - Rasterize a monochrome elliptical tip from computed-brush geometry.
- tip_
bitmap_ of - Both formats use the same polarity — a
Shape.pngis white=stamp coverage and aTipBitmapis 255=full ink — so the pixels are copied unchanged. - to_
grayscale