This project is read-only.

About WriteableBitmapEx

Oct 5, 2012 at 5:48 PM
Edited Oct 5, 2012 at 5:49 PM


1) When I run the following instruction, I got the " Value does not fall within the expected range" exception. ImagePath is aslo contained correct uri.

WriteableBitmap wbTemp = await wbResize.FromContent(new Uri(ImageUriPath, UriKind.Absolute));

2) byte[] btarrImage = await httpClient.GetByteArrayAsync(ImageUriPath);wbResize = wbResize.FromByteArray(btarrImage);
await wbResize.SaveToFile(ApplicationData.Current.LocalFolder, "Test.jpg");

After running above 3 lines, image can't save correctly.


Oct 5, 2012 at 6:21 PM

You can't just pass an uri to the FromContent method. It's only for local images, not remote.

Use the FromStream method with the httpClient.GetStream method as input.


- rene schulte

Oct 8, 2012 at 5:25 AM


Thanks for your quick reply.

When I use httpClient.GetStreamAsync(uristring), it return Stream.

FromStream method  allow only IRandomAccessStream.

Thus type mismatch compiler errors occurred.

How can I do? Please help me.


Oct 8, 2012 at 12:14 PM

I just checked in another overload for the FromStream method which takes a .NET stream directly:

      public static async Task<WriteableBitmap> FromStream(this WriteableBitmap bmp, Stream stream)
         using (var dstStream = new InMemoryRandomAccessStream())
            await RandomAccessStream.CopyAsync(stream.AsInputStream(), dstStream);
            return await FromStream(bmp, dstStream);

Get the latest source code from the respository or use this method above.


- Rene

Oct 8, 2012 at 12:21 PM

Thanks you very much, I will try with this way.