public BitmapSource DrawHud(BitmapSource cameraImage) { if (!showHud) { return(cameraImage); } Bitmap currentBitmap = drawingUtils.BitmapFromSource(cameraImage); foreach (HudElement element in hudElements) { element.InitBaseVariables(currentBitmap, currentState); currentBitmap = element.DrawToImage(currentBitmap, currentState); } BitmapSource resultingSource = drawingUtils.BitmapToSource(currentBitmap); currentBitmap.Dispose(); return(resultingSource); }