Skip to main content

Module imagediff

Module imagediff 

Source
Expand description

Graphical diffing of image blobs.

When a changed file is an image, a unified text diff is useless (“Binary files differ”). Instead journey decodes the two sides and shows them visually. This module is the pure, toolkit-independent half: it decodes the BlobPair the backend hands over and composes the two images into a single ARGB Canvas for one of several comparison modes — the same set the author’s imgap CLI offers interactively:

  • 2-up — the before/after images side by side.
  • Swipe — a single frame split left-from-old, right-from-new, the split following a 0..1 slider.
  • Onion skin — the two cross-faded by the slider.
  • Difference — a heatmap of per-pixel difference (black = identical, through blue/green/yellow to red = maximal; magenta where the images differ in size, so don’t overlap).
  • Left / Right — just one side, full size.

ImageComparison owns the decoded images, a cache of the fit-scaled buffers, and the last fully-composed Canvas keyed by what produced it — so ImageComparison::render is cheap to call every frame: an unchanged repaint (a caret blink, a scroll in another pane) returns the cached canvas without re-scaling or re-compositing. The widget that drives it lives in crate::widgets::ImageDiffView.

Structs§

Canvas
A composed, fully-opaque ARGB image ready to blit, sized to the actual content (≤ the box passed to ImageComparison::render, which centers it).
ImageComparison
The decoded two sides of an image change, plus a metadata summary line.

Enums§

CompareMode
One of the ways the two images can be compared.

Functions§

is_image_path
Whether path looks like a raster image worth showing graphically.