在Windows Phone 7上将图像转换为字节数组没有System.Drawing Dll任何其他方式?

时间:2012-04-30 14:49:18

标签: image windows-phone-7 binary system.drawing

Byte[] result = (Byte[])new ImageConverter().ConvertTo(img1, typeof(Byte[]));

//I cant use Image Converter add Image Class ? Drawing dll 

MemoryStream ms = new MemoryStream();

img1.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);

return ms.ToArray();

//Cannot see System.Drawing dll and there is no  sth like Drawing.Imaging... 

还有其他选项,而不是从外部源添加dll(我的意思是我会复制它,然后将其添加为外部dll)?我的项目是在Windows 7手机应用程序中,无法看到像那样的Drwaing.dll stj

由于

1 个答案:

答案 0 :(得分:5)

首先,WP7中没有 system.drawing

您可以这样做:

MemoryStream ms = new MemoryStream();
WriteableBitmap wb = new WriteableBitmap(myimage);
wb.SaveJpeg(ms, myimage.PixelWidth, myimage.PixelHeight, 0, 100);
byte [] imageBytes = ms.ToArray();