So my app gets a BitmapImage from a url, which works, and I then need to assign that image to a writeablebitmap. For the moment I have this:
Debug.WriteLine("Poster opened for loading. Url=" + e);
BitmapImage img = new BitmapImage(new Uri(e));
Backdrop.Source = img;
img.ImageOpened += async (s, e1) =>
{
WriteableBitmap wbm = new WriteableBitmap(((BitmapImage)s).PixelWidth, ((BitmapImage)s).PixelHeight);
var storageFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri(e));
using (var stream = await storageFile.OpenReadAsync())
{
await wbm.SetSourceAsync(stream);
}
};
Which is really awful code, but it all works until StorageFile.GetFileFromApplicationUriAsync()
, where I'm told the Value falls within an unexpected range. I'm guessing this is because it only acceps the "ms-appx:///" format, and not "http://". Is there any way to get this working? And eventually in a cleaner way?
I thought this would be easy, but it's a nightmare. I've been trying to do this since yesterday.
P.S. I know this might appear like a duplicate, but I have found absolutely nothing on StackOverflow that actually works.