private string SaveBmp(BitmapEncoder encoder, FrameworkElement element, double height, double width) { var outPath = getOutPath(); string extend = ".png"; if (encoder is JpegBitmapEncoder) { extend = ".jpg"; } else if (encoder is BmpBitmapEncoder) { extend = ".bmp"; } var savePath = outPath + "Report_" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff") + extend; encoder.Frames.Add(BitmapFrame.Create(CommunicationHelper.GetElementBitmap(element, height, width))); using (Stream stm = File.Create(savePath)) { encoder.Save(stm); } return(savePath); }