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); }
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); }