public static BitmapImage LoadBitmapImage(this string path, int w, int h) { try { using (var ms = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { var image = new BitmapImage(); image.BeginInit(); if (w > 0 & h > 0) { image.DecodePixelHeight = h; image.DecodePixelWidth = w; } image.CacheOption = BitmapCacheOption.OnLoad; image.StreamSource = ms; image.EndInit(); return(image); } } catch (Exception ex) { ErrorHelper.ErrorPutting(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); return(null); } finally { MemoryHepler.FlushMemory(); } }
public virtual void Dispose(bool isDisplsed) { if (isDisplsed) { return; } if (DocumentPrint != null) { DocumentPrint.Dispose(); } if (PrintBitmap != null) { PrintBitmap.Dispose(); } MemoryHepler.FlushMemory(); }