BarrierLab

visual-evidence

In-memory visual evidence: crops, RGBA highlight overlays, 5x7 badges and byte-stable SHA-256 manifests.

Layer L1. Turns a screenshot and finding coordinates into reproducible visual evidence, entirely in memory. Builds on pixel-diff for RgbaView, RgbaImage and PixelRect. No file system, no clock, no browser.

Status

New, not yet released. Consumer: visual-audit and the auditors above it.

What the package does

  • Crop: crop_with_padding(src, target, padding) cuts the target plus context out of the image. Padding and target are clamped with saturating arithmetic; CropResult returns the clamped source_region and the clamped target relative to the crop (target_in_crop). Empty targets (EmptyRegion) and targets starting outside the image (RegionOutOfBounds) are errors, never panics.
  • Overlays: render_overlay (copy) and draw_annotations (in place) draw, per Annotation, a frame inside the rectangle (stroke_width, may fill the whole rect), an optional translucent fill of the interior and an optional index badge at the top-left corner. All frames come first, badges last. dim_outside darkens everything outside given rectangles (spotlight).
  • Badges: built-in 5x7 digit bitmaps at scale 2 in an opaque box of the stroke colour; digits are black or white depending on the box luminance.
  • Compositing: Porter-Duff source-over on non-premultiplied RGBA8 in integer arithmetic, rounding half up; alpha 255 overwrites, 0 is a no-op.
  • Manifest: EvidenceManifest / EvidenceItem with to_json and from_json. Fixed field order, Vec only, no system time (captured_at comes from the host), so equal manifests serialize to identical bytes.
  • Hashing (hash, default): sha256_hex(bytes) and sha256_rgba_hex(view), which hashes width and height (u32 little-endian) followed by the raw RGBA8 bytes: the same pixels give the same hash with or without PNG. Uses sha2 0.10 without default features.
  • PNG (png): encode_png, crop_to_png, render_overlay_png.

Without hash the manifest type is unchanged; hash strings are then supplied by the host and from_screenshot / from_crop are not available.

What the package does not do

No disk I/O, no PDF or HTML reports, no rule evaluation, no font rendering (only digits 0-9 for badges).

Edit this page on GitHub