public static BitmapImage AsBitmapImage(this byte[] byteArray) { if (byteArray != null) { using (var stream = new InMemoryRandomAccessStream().AsStreamForWrite()) { stream.Write(byteArray, 0, byteArray.Length); var image = new BitmapImage(); stream.Seek(0, 0); image.SetSource(stream.AsRandomAccessStream()); return(image); } } return(null); }