public BitmapSource GetNormalImageSource(Rectangle section, bool flipX = false, bool flipY = false) { BitmapSource source; Bitmap bmp; if (StandardSourceCache.TryGetValue(new CacheKey(section, flipX, flipY), out source)) { return(source); } else { bmp = CropImage(StandardBitmap, section); if (flipX) { bmp.RotateFlip(RotateFlipType.RotateNoneFlipX); } if (flipY) { bmp.RotateFlip(RotateFlipType.RotateNoneFlipY); } source = Extensions.ImageExtensions.ToBitmapSource(bmp); StandardSourceCache.Add(new CacheKey(section, flipX, flipY), source); return(source); } }
private void DisposeSourceCache() { if (null == StandardSourceCache) { return; } StandardSourceCache.Clear(); }