diff --git a/README.md b/README.md index 7caf2ce..e35b78b 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,8 @@ Default usage: var secondImage = new Bitmap("path/to/second/image); var comparer = new BitmapComparer(); - var diff = comparer.Compare(firstImage, secondImage); + var diff = comparer.Compare(firstImage, secondImage); //Returns a result with the differences + the Bitmap + var generate = comparer.Generate(firstImage, secondImage);// Generates the bitmap image and returns a Bitmap When initialized without options, the following values are used: @@ -36,19 +37,21 @@ When initialized without options, the following values are used: - BoundingBoxPadding: 2 - BoundingBoxColor: Red - BoundingBoxMode: Single +- BoundingBoxThickness: 1 The compare object can be configured to use different settings for the different stages of processing. var options = new CompareOptions { - AnalyzerType = AnalyzerTypes.CIE76, + AnalyzerType = AnalyzerTypes.CIE76, JustNoticableDifference = 2.3, DetectionPadding = 2, Labeler = LabelerTypes.ConnectedComponentLabeling, BoundingBoxColor = Color.Red, BoundingBoxPadding = 2, - BoundingBoxMode = BoundingBoxModes.Multiple + BoundingBoxMode = BoundingBoxModes.Multiple, + BoundingBoxThickness = 1 }; var comparer = new BitmapComparer(options); @@ -76,6 +79,10 @@ The color of the bounding box to be drawn when highlighting detected differences #### Bounding Box Padding The number of pixels of padding to include around the detected difference when drawing a bounding box. +#### Bounding Box Thickness +The thickness of the rectangle showing the difference in pixel. Default = 1 + + #### Bounding Box Mode Specifies how to build the bounding boxes when highlighting the detected differences. diff --git a/src/.vs/ImageDiff/v16/TestStore/0/009.testlog b/src/.vs/ImageDiff/v16/TestStore/0/009.testlog new file mode 100644 index 0000000..6eedade Binary files /dev/null and b/src/.vs/ImageDiff/v16/TestStore/0/009.testlog differ diff --git a/src/.vs/ImageDiff/v16/TestStore/0/testlog.manifest b/src/.vs/ImageDiff/v16/TestStore/0/testlog.manifest new file mode 100644 index 0000000..ce543b7 Binary files /dev/null and b/src/.vs/ImageDiff/v16/TestStore/0/testlog.manifest differ diff --git a/src/ImageDiff/BitmapComparer.cs b/src/ImageDiff/BitmapComparer.cs index 78619ba..6e9510c 100644 --- a/src/ImageDiff/BitmapComparer.cs +++ b/src/ImageDiff/BitmapComparer.cs @@ -15,6 +15,7 @@ public class BitmapComparer : IImageComparer private int DetectionPadding { get; set; } private int BoundingBoxPadding { get; set; } private Color BoundingBoxColor { get; set; } + private int BoundingBoxThickness { get; set; } private BoundingBoxModes BoundingBoxMode { get; set; } private AnalyzerTypes AnalyzerType { get; set; } @@ -47,21 +48,31 @@ private void Initialize(CompareOptions options) BoundingBoxPadding = options.BoundingBoxPadding; BoundingBoxMode = options.BoundingBoxMode; AnalyzerType = options.AnalyzerType; + BoundingBoxThickness = options.BoundingBoxThickness; } - public Bitmap Compare(Bitmap firstImage, Bitmap secondImage) + + + public Bitmap Generate(Bitmap firstImage, Bitmap secondImage) + { + Result result = Compare(firstImage, secondImage); + return result.Image; + } + + public Result Compare(Bitmap firstImage, Bitmap secondImage) { if (firstImage == null) throw new ArgumentNullException("firstImage"); if (secondImage == null) throw new ArgumentNullException("secondImage"); if (firstImage.Width != secondImage.Width || firstImage.Height != secondImage.Height) throw new ArgumentException("Bitmaps must be the same size."); - + var differenceMap = BitmapAnalyzer.Analyze(firstImage, secondImage); var differenceLabels = Labeler.Label(differenceMap); var boundingBoxes = BoundingBoxIdentifier.CreateBoundingBoxes(differenceLabels); var differenceBitmap = CreateImageWithBoundingBoxes(secondImage, boundingBoxes); - return differenceBitmap; + return Result.Create(differenceBitmap, boundingBoxes); } + public bool Equals(Bitmap firstImage, Bitmap secondImage) { if (firstImage == null && secondImage == null) return true; @@ -95,7 +106,8 @@ private Bitmap CreateImageWithBoundingBoxes(Bitmap secondImage, IEnumerable where T : Image { - T Compare(T firstImage, T secondImage); + T Generate(T firstImage, T secondImage); + Result Compare(T firstImage, T secondImage); bool Equals(T firstImage, T secondImage); } } \ No newline at end of file diff --git a/src/ImageDiff/ImageDiff.csproj b/src/ImageDiff/ImageDiff.csproj index c984cd3..2688ca0 100644 --- a/src/ImageDiff/ImageDiff.csproj +++ b/src/ImageDiff/ImageDiff.csproj @@ -56,6 +56,7 @@ +