有没有办法到的BitmapImage(Windows.UI.Xaml.Media.BitmapImage)转换为byte []数组? 没什么我已经试过工作....另一种可能的方案(如果BitmapImage的不能被转换为字节数组)是从网站上下载图像,然后将其转换为一个数组...
但我不知道我该怎么做......这将是非常好的,如果有人有一个想法。
目前的尝试:
HttpClient http = new HttpClient();
Stream resp = await http.GetStreamAsync("http://localhost/img/test.jpg");
var ras = new InMemoryRandomAccessStream();
await resp.CopyToAsync(ras.AsStreamForWrite());
BitmapImage bi = new BitmapImage();
bi.SetSource(ras);
byte[] pixeBuffer = null;
using (MemoryStream ms = new MemoryStream())
{
int i = bi.PixelHeight;
int i2 = bi.PixelWidth;
WriteableBitmap wb = new WriteableBitmap(bi.PixelWidth, bi.PixelHeight);
Stream s1 = wb.PixelBuffer.AsStream();
s1.CopyTo(ms);
pixeBuffer = ms.ToArray();
}
但它不工作...我和I2总是设置为0,所以ras基因不能正常工作....这是怎么回事?
谢谢