-
Notifications
You must be signed in to change notification settings - Fork 9
How to get images
Yauheni Pakala edited this page Apr 26, 2016
·
2 revisions
// Example method for Windows Phone 8.1+
public async Task<BitmapImage> ConvertToBitmapImage(byte[] image)
{
// converting stream
InMemoryRandomAccessStream ras = new InMemoryRandomAccessStream();
var memoryStream = new MemoryStream(image);
await memoryStream.CopyToAsync(ras.AsStreamForWrite());
// create BitmapImage
var bitmapImage = new BitmapImage();
await bitmapImage.SetSourceAsync(ras);
return bitmapImage;
}
Get image from book ImageLine
//
var image = ((ImageLine)line);
// create image on wp 8.1
Image img = new Image();
img.Source = await ConvertToBitmapImage(image.Data);
var cover = _file.Images.FirstOrDefault(i => i.Key.Contains("cover"));
if (cover.Key != null)
{
try
{
Image img = new Image();
img.Source = await ConvertToBitmapImage(cover.Value.BinaryData);
bookContent.Children.Add(img);
}
catch (Exception)
{
}
}