/// <summary> /// Called after all the data is collected. /// </summary> public virtual void PostProcess() { IScreenShotAnnotator screenShotAnnotator = this as IScreenShotAnnotator; if (screenShotAnnotator != null) { if (ScreenGrabs.AllGrabs.Count > 0) { AnnotateScreenshot(screenShotAnnotator, ScreenGrabs.AllGrabs[0]); } } }
void AnnotateScreenshot(IScreenShotAnnotator screenShotAnnotator, ScreenGrab screenGrab) { DrawingVisual visual = new DrawingVisual(); double screenGrabWidth = screenGrab.Image.Width; double screenGrabHeight = screenGrab.Image.Height; using (DrawingContext drawingContext = visual.RenderOpen()) { drawingContext.DrawImage(screenGrab.Image, new Rect(0, 0, screenGrabWidth, screenGrabHeight)); screenShotAnnotator.AnnotateScreenshot(drawingContext, screenGrab); } RenderTargetBitmap newImage = new RenderTargetBitmap((int)screenGrabWidth, (int)screenGrabHeight, 96, 96, PixelFormats.Pbgra32); newImage.Render(visual); screenGrab.Image = newImage; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); }