Convert image to byte array on Windows Phone 7 No System.Drawing Dll any other way?

会有一股神秘感。 提交于 2019-12-02 10:37:51

问题


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... 

Is there any other option rather than adding dll from the out source(I mean I ll copy it and then add it as an external dll )? My project is in windows 7 phone application and can not see Drwaing.dll stj like that

Thanks


回答1:


First there is no system.drawing in WP7.

You can do something like this:

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


来源:https://stackoverflow.com/questions/10385642/convert-image-to-byte-array-on-windows-phone-7-no-system-drawing-dll-any-other-w

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!