예제 #1
0
        private async Task <SKBitmapRefCounted> LoadBitmap(string path)
        {
            var skBitmap = await SKBitmapLoader.Load(path, CancellationToken.None);

            var skBitmapRefCounted = new SKBitmapRefCounted(skBitmap);

            _bitmaps[path] = new WeakReference <SKBitmapRefCounted>(skBitmapRefCounted);
            skBitmapRefCounted.Share();
            return(skBitmapRefCounted);
        }
예제 #2
0
 private bool TryGetBitmap(string path, out SKBitmapRefCounted bitmap)
 {
     bitmap = null;
     if (!_bitmaps.TryGetValue(path, out var reference) || !reference.TryGetTarget(out bitmap))
     {
         return(false);
     }
     if (bitmap.IsDisposed)
     {
         return(false);
     }
     bitmap.Share();
     return(true);
 }