/// <summary> /// Creates a WIC BitmapSource object from the given source. /// </summary> /// <param name="resourceLink">The source of the resource.</param> public static async Task <WicBitmapSource> FromResourceSourceAsync(ResourceLink resourceLink) { WicBitmapSourceInternal?wicBitmapSource = null; using (var inStream = await resourceLink.OpenInputStreamAsync()) { wicBitmapSource = await SeeingSharpUtil.CallAsync(() => GraphicsHelper.Internals.LoadBitmapSource(inStream)); } return(new WicBitmapSource(wicBitmapSource)); }
/// <summary> /// Creates a WIC bitmap from the given source. /// </summary> /// <param name="resourceLink">The source of the resource.</param> public static async Task <WicBitmap> FromResourceLinkAsync(ResourceLink resourceLink) { GraphicsCore.EnsureGraphicsSupportLoaded(); IWICBitmap?wicBitmap = null; using (var inStream = await resourceLink.OpenInputStreamAsync()) using (var bitmapSourceWrapper = await SeeingSharpUtil.CallAsync(() => GraphicsHelper.Internals.LoadBitmapSource(inStream))) { wicBitmap = GraphicsCore.Current.FactoryWIC !.CreateBitmapFromSource( bitmapSourceWrapper.Converter, BitmapCreateCacheOption.CacheOnLoad); } return(new WicBitmap(wicBitmap)); }