且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Windows 8.1存储应用程序中将图像转换为字节数组?

更新时间:2023-11-13 10:46:04

虽然我没有开发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();