diff --git a/src/AudioAnalysisTools/AcousticEvent.cs b/src/AudioAnalysisTools/AcousticEvent.cs index 02714912b..8700effbd 100644 --- a/src/AudioAnalysisTools/AcousticEvent.cs +++ b/src/AudioAnalysisTools/AcousticEvent.cs @@ -477,8 +477,7 @@ public void DrawEvent(Image imageToReturn, double framesPerSecond, double imageToReturn.Mutate(g => { g.NoAA().DrawLine(scorePen, t1, y2 - scoreHt, t1, y2 + 1); - //g.DrawTextSafe(this.Name, Drawing.Tahoma6, Color.Black, new PointF(t1, y1 - 5)); - g.DrawTextSafe(this.Name, Drawing.Arial8, Color.Black, new PointF(t1, y1 - 5)); + g.DrawTextSafe(this.Name, Drawing.Tahoma6, Color.Black, new PointF(t1, y1 - 4)); }); } diff --git a/tests/Acoustics.Test/AudioAnalysisTools/AcousticEvents/EventTests.cs b/tests/Acoustics.Test/AudioAnalysisTools/AcousticEvents/EventTests.cs index fcbad433f..a1be7e530 100644 --- a/tests/Acoustics.Test/AudioAnalysisTools/AcousticEvents/EventTests.cs +++ b/tests/Acoustics.Test/AudioAnalysisTools/AcousticEvents/EventTests.cs @@ -6,13 +6,14 @@ namespace Acoustics.Test.AudioAnalysisTools.EventStatistics { using System; using System.Collections.Generic; + using Acoustics.Test.TestHelpers; using global::AudioAnalysisTools; using Microsoft.VisualStudio.TestTools.UnitTesting; using SixLabors.ImageSharp; using SixLabors.ImageSharp.PixelFormats; [TestClass] - public class EventTests + public class EventTests : GeneratedImageTest { [TestMethod] public void TestEventMerging() @@ -103,26 +104,28 @@ public void TestSonogramWithEventsOverlay() // set colour for the events foreach (AcousticEvent ev in events) { + // do not set an event name because text is not drawing anit-aliased at present time. + ev.Name = string.Empty; ev.BorderColour = AcousticEvent.DefaultBorderColor; ev.ScoreColour = AcousticEvent.DefaultScoreColor; ev.DrawEvent(substituteSonogram, framesPerSecond, freqBinWidth, height); } - substituteSonogram.Save("C:\\temp\\image.png"); - - var redPixel = new Argb32(220, 20, 60); - var expectedRed = new Color(redPixel); - var greenPixel = new Argb32(0, 255, 0); - var expectedGreen = new Color(greenPixel); - - Assert.AreEqual(expectedRed, substituteSonogram[60, 119]); - Assert.AreEqual(expectedRed, substituteSonogram[70, 122]); - Assert.AreEqual(expectedRed, substituteSonogram[90, 181]); - Assert.AreEqual(expectedRed, substituteSonogram[36, 232]); - Assert.AreEqual(expectedRed, substituteSonogram[56, 69]); - - Assert.AreEqual(expectedGreen, substituteSonogram[10, 72]); - Assert.AreEqual(expectedGreen, substituteSonogram[70, 217]); + substituteSonogram.Save("C:\\temp\\EventTests_SuperimposeEventsOnImage.png"); + + this.Actual = substituteSonogram; + /* + var pattern = @" +⬇150 +E100R50 +48×E100RE48R +E100R50 +"; + this.Expected = TestImage.Create(width: 100, height: 100, Color.Black, pattern); + */ + + this.Expected = Image.Load(PathHelper.ResolveAssetPath("EventTests_SuperimposeEventsOnImage.png")); + this.AssertImagesEqual(); } } } diff --git a/tests/Fixtures/EventTests_SuperimposeEventsOnImage.png b/tests/Fixtures/EventTests_SuperimposeEventsOnImage.png new file mode 100644 index 000000000..b45eba20e --- /dev/null +++ b/tests/Fixtures/EventTests_SuperimposeEventsOnImage.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4fde5d7e3427a88eae8774bebb0b986b301edee6808d37bc41a3479d7320cc6e +size 699