![](/img/trans.png)
[英]How to convert pixel byte array to bitmap image in windows phone 8
[英]How to convert Image to Bitmap or Byte Array
我想把一个Image翻译成一个MemoryStream或者一个字节数组,但是这不起作用,我以前在Windows Forms中翻译的方式和我在Xamarin.Forms中的翻译方式一样吗?
MemoryStream ms = new MemoryStream();
img.Save(ms, img.Image.RawFormat);
byte[] byteimg = ms.ToArray();
Unlike Windows.Forms or WPF where the Image class has direct access to pixels and can provide the entirety of image manipulation APIs, Image class in Xamarin Forms is just an abstraction for multiple platform views across OSes (Android, iOS, macOS etc.) It provides limited与任何平台控件相比的功能,主要任务是创建平台视图,从预定义源之一(嵌入式资源、文件、字节 stream 等)加载图片,将其放置在可视化树中的某个位置。 就是这样,XF Image class 不负责低级像素操作,也不提供对原始图像的实际位数据的访问。 你不会找到让你访问像素的方法,因此不允许你从加载到 memory 字节的数据中创建 Stream。
为了访问单个字节,您可以:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.