예제 #1
0
        public static BitmapInfo SaveToCache(SKBitmap bitmap, string fileName, bool dispose = true)
        {
            var info = new BitmapInfo
            {
                Width    = bitmap.Width,
                Height   = bitmap.Height,
                FileName = fileName
            };

            using (var image = SKImage.FromBitmap(bitmap))
                using (var data = image.Encode(SKEncodedImageFormat.Png, 100))
                    using (var stream = File.OpenWrite($"{Root}Cache/{fileName}.png"))
                        data.SaveTo(stream);

            if (dispose)
            {
                bitmap.Dispose();
            }

            return(info);
        }
예제 #2
0
 public static SKBitmap LoadFromCache(BitmapInfo info) => LoadFromCache(info.FileName);