Compare images in the viewer - #753
Merged
Merged
Conversation
Image files are compared as pictures rather than as text, wherever they turn up: a pair passed on the command line, or a move or delete the tray is holding. Previously they were read as text, which meant a pane of mojibake, and DiffEngine never routed one here at all. FileSide.Read decides text or picture by extension, because the expected side of a brand new snapshot has no bytes to sniff and still has to render as a missing image rather than empty text. ImageRows then produces the same aligned Row lists DiffRows does, one per property and coloured against the other side, so an image comparison is described by rows every head already draws. Whether the two are the same file belongs to the pair rather than to either side, so it is the status line. Pane.Image is an enrichment on top of that: all three heads paint the picture under those rows, each with its toolkit's own decoder, so which formats draw is per platform while what the comparison says is not. All three fit from the file header's dimensions rather than the decoder's, one blank line under the pane's rows, so the placement rule lives in one place. Headers are sniffed by hand rather than by System.Drawing, which does not exist on macOS or Linux, and the extension list lives in DiffEngine and is linked into the viewer so the tool registration and the renderer cannot disagree. DEVIEW_VERSION 6: DeviewPane carries the picture. That widens an array element, so an older library would read every pane after the first at the wrong offset and the committed native binaries have to be rebuilt before they will load.
Co-authored-by: SimonCropp <122666+SimonCropp@users.noreply.github.com>
DiffRunnerTests reads two fixtures from beside its own source file, and one of them was missing from the working tree and got swept into the previous commit as a deletion. LaunchAsync guards that both paths exist before it does anything else, so the four launch tests failed on the Windows CI job.
Captured by the Linux and macOS jobs, which build the shim from source, so they describe the renderers in this branch rather than the committed binaries. Both heads draw the two pictures at native size, one blank line under the property rows, on a checkerboard the transparent half shows through. The byte counts read the same on all three platforms, which is what SamplePng's stored deflate blocks are for.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Image files are compared as pictures rather than as text, wherever they turn up: a pair passed on the command line, or a move or delete the tray is holding. Previously they were read as text, which meant a pane of mojibake — and DiffEngine never routed one to the viewer at all, since its
BinaryExtensionswas empty.An image is a side, not a mode
FileSide.Read(the renamedFileText) decides text or picture by extension. It has to be the extension rather than sniffed content, because the expected side of a brand new snapshot has no bytes to sniff and still has to render as a missing image rather than as empty text.ImageRowsthen produces the same alignedRowlistsDiffRowsdoes — one row per property, each carrying its own side's value and coloured against the other, so a matching format reads unchanged and a differing size reads modified. An image comparison is therefore described by rows every head already draws.Whether the two are the same file belongs to the pair rather than to either side, so it is the status line:
images are identical,images differ, oronly <file> exists, which is the normal state of a new image snapshot.The picture is an enrichment on top
Pane.Imagecarries a path and the file header's dimensions. All three heads paint the picture under those rows — Windows with GDI+, macOS with ImageIO, Linux with raylib — so which formats draw is per platform while what the comparison says is not. A format a head cannot decode draws nothing and the rows still carry the comparison, which is the property the ASCII snapshots pin.All three fit from
ImagePane.Width/Heightrather than from their own decoder, one blank line under the pane's rows, so the placement rule lives in one place instead of three..png.jpg.jpeg.gif.bmp.ico.png.jpg.jpeg.gif.bmpABI
DEVIEW_VERSION6:DeviewPanegained the picture. That widens an array element, so an older library would read every pane after the first at the wrong offset — this is a bump worth honouring. The rebuilt binaries are in this branch already (#752).Notes
ImageHeader) rather than by System.Drawing, which does not exist on macOS or Linux. Recognising the format and reading the size are separate answers, so a truncated JPEG stays a JPEG of unknown size.Outstanding
PixelTests.Imageshas no Linux or macOS baseline yet — this PR's firsttest.ymlrun is what produces them, as*.received.*artifacts to accept.🤖 Generated with Claude Code