// Render to a bitmap and check against the saved version. internal void CheckHighlightBitmap(CourseObj courseobj, string basename) { Bitmap bmNew = RenderToBitmap(courseobj, Color.White); Bitmap bmEraseBrush = (Bitmap) bmNew.Clone(); Bitmap bmHighlighted = (Bitmap) bmNew.Clone(); Matrix matrix = GetTransform(bmNew.Size); using (Graphics g = Graphics.FromImage(bmHighlighted)) { g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel; courseobj.DrawHighlight(g, matrix); } Bitmap bmErased = (Bitmap) bmHighlighted.Clone(); TestUtil.CheckBitmapsBase(bmHighlighted, "coursesymbols\\" + basename); using (TextureBrush eraseBrush = new TextureBrush(bmEraseBrush)) using (Graphics g = Graphics.FromImage(bmErased)) { g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel; courseobj.EraseHighlight(g, matrix, eraseBrush); } Bitmap bmDiff; bmDiff = TestUtil.CompareBitmaps(bmNew, bmErased, Color.LightPink, Color.Transparent, 0); if (bmDiff != null) bmDiff.Save(TestUtil.GetTestFile("coursesymbols\\" + basename + "_diff.png"), ImageFormat.Png); Assert.IsNull(bmDiff, "after erase does not match with before highlight"); bmEraseBrush.Dispose(); }