如何在Windows 8.1存储应用程序中将图像转换为字节数组? [英] How to convert Image to byte array in windows 8.1 Store apps?
本文介绍了如何在Windows 8.1存储应用程序中将图像转换为字节数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Windows 8.1商店应用开发中将图像转换为字节数组。
目前我正在使用这个
How to convert image to byte array in windows 8.1 store apps developing.
present i am using this
MemoryStream ms = new MemoryStream();
WriteableBitmap wb = new WriteableBitmap(myimage);
wb.SaveJpeg(ms, myimage.PixelWidth, myimage.PixelHeight, 0, 100);
byte [] imageBytes = ms.ToArray();
以上代码适用于Windows Phone 8.1但我想要它对于Windows 8.1商店应用。
,如何转换请帮帮我...
谢谢。
The above code is for windows phone 8.1 but i want it for windows 8.1 store app.
, How to convert please help me...
thanks.
推荐答案
虽然我没有开发Win Store应用程序,但快速查看SaveJpeg的文档表明你缺少参数:[ ^ ]。
While I do not develop Win Store apps, a quick look at the documentation for 'SaveJpeg suggests you are missing arguments: [^].
SaveJpeg(
this WriteableBitmap bitmap,
Stream targetStream,
int targetWidth,
int targetHeight,
int orientation,
int quality
)
它还向我跳出你创建一个内存流然后不做任何事情将图像数据导入流中的事情。
在System.Drawing.Image中将图像内容作为byte []的典型代码:
It also "jumps out at me" that you create a memory stream and then do not do anything to get the image data into the stream.
Typical code to get Image contents as byte[] in System.Drawing.Image:
MemoryStream ms = new MemoryStream();
YourImage.Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] bAry = ms.ToArray();
这篇关于如何在Windows 8.1存储应用程序中将图像转换为字节数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文