Skip to main content

Crate brushkit_preview

Crate brushkit_preview 

Source
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 .brush and .brushset archives: the guarded zip and plist readers, the Shape.png decoder and the two name/member lookups the preview API needs.

Structs§

ContactSheetConfig
GrayscaleBitmap
PreviewEntry
PreviewError
PreviewOptions
PreviewSet
SheetBrush
SourceDimensions
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 preview reads.
SheetBackground
Take
Which entries a preview returns.
TipImageError
TipPreview
UnavailableReason

Constants§

MAX_IMPORT_DECODED_BYTES
The decode budget of decode_tip_image. TipImageError::TooLarge lists what it reserves.
MAX_IMPORT_DIMENSION
MAX_PREVIEW_BYTES
The most bytes of bitmap data (GrayscaleBitmap::data) the Available tips of one preview call, 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 bitmap so its larger side is at most max_side (>= 1). Returns a clone when it already fits. Average of the covered source pixels per destination pixel, the same filter generate_preview_png uses.
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, as take selects them.
preview_abr
Tips for a Photoshop .abr pack.
preview_abr_first_available
The first n entries of preview_abr whose tip is available, in the same order and with the same index they have there, so indices may skip. Unavailable entries do not count toward n, and entries after the nth available one or after the first OverBudget one 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_brush limited to available tips: its single entry when the tip is available and n >= 1, otherwise no entries. With n == 0 the tip is not decoded.
preview_brushset
Tips for a Procreate .brushset.
preview_brushset_first_available
The first n entries of preview_brushset whose tip is available, in the same order and with the same index they have there, so indices may skip. Unavailable entries do not count toward n, and members after the nth available one or after the first OverBudget one 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.png is white=stamp coverage and a TipBitmap is 255=full ink — so the pixels are copied unchanged.
to_grayscale