Esempio n. 1
0
        public BitmapSource GetTransparentImageSource(Rectangle section, bool flipX = false, bool flipY = false)
        {
            BitmapSource source;
            Bitmap       bmp;

            if (TransparentSourceCache.TryGetValue(new CacheKey(section, flipX, flipY), out source))
            {
                return(source);
            }
            else
            {
                bmp = CropImage(TransparentBitmap, section);
                if (flipX)
                {
                    bmp.RotateFlip(RotateFlipType.RotateNoneFlipX);
                }
                if (flipY)
                {
                    bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
                }

                source = Extensions.ImageExtensions.ToBitmapSource(bmp);
                TransparentSourceCache.Add(new CacheKey(section, flipX, flipY), source);
                return(source);
            }
        }
Esempio n. 2
0
 private void DisposeOpaqueSourceCache()
 {
     if (null == TransparentSourceCache)
     {
         return;
     }
     TransparentSourceCache.Clear();
 }