ImageComparer Class

Compares image snapshots by their pixels, exactly or by similarity when ImageComparisonSettings sets a threshold. Every format Meziantou.Framework.Imaging decodes is supported. Every frame is compared: the frames of an animation, the pages of a TIFF file and the representations of an ICO or CUR file.

public sealed class ImageComparer : ISnapshotComparer
Implements

Constructors

NameDescription
ImageComparer(ImageComparisonSettings?)Compares image snapshots by their pixels, exactly or by similarity when ImageComparisonSettings sets a threshold. Every format Meziantou.Framework.Imaging decodes is supported. Every frame is compared: the frames of an animation, the pages of a TIFF file and the representations of an ICO or CUR file.

ImageComparer(ImageComparisonSettings?)

ImageComparer.cs

Compares image snapshots by their pixels, exactly or by similarity when ImageComparisonSettings sets a threshold. Every format Meziantou.Framework.Imaging decodes is supported. Every frame is compared: the frames of an animation, the pages of a TIFF file and the representations of an ICO or CUR file.

public ImageComparer(ImageComparisonSettings? settings = null)

Parameters

settings ImageComparisonSettings?

Methods

NameDescription
Equals(SnapshotData, SnapshotData)Compares two snapshots.
Equals(SnapshotData, SnapshotData, string?)Compares two snapshots and, when they do not match, describes why.

Equals overloads

Equals(SnapshotData, SnapshotData)

ImageComparer.cs

Compares two snapshots.

public bool Equals(SnapshotData expected, SnapshotData actual)
Parameters
expected SnapshotData
The verified snapshot.
actual SnapshotData
The snapshot produced by the test.
Returns

bool true when the snapshots match.

Equals(SnapshotData, SnapshotData, string?)

ImageComparer.cs

Compares two snapshots and, when they do not match, describes why.

public bool Equals(SnapshotData expected, SnapshotData actual, out string? mismatchReason)
Parameters
expected SnapshotData
The verified snapshot.
actual SnapshotData
The snapshot produced by the test.
mismatchReason string?
When the snapshots do not match, a short description of the difference that is added to the assertion message (for example, the similarity score and the threshold it did not reach), or null when the comparer has nothing to add. Always null when the snapshots match.
Returns

bool true when the snapshots match.

Remarks

The default implementation calls ISnapshotComparer.Equals and gives no reason.