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

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 than adding a dll from the original source (I mean, I will copy it and then add it as an external dll)? My project is in a Windows 7 application and cannot see Drwaing.dll stj like this

thank

+1
source share
1 answer

At 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();
+5
source

Source: https://habr.com/ru/post/1541551/


All Articles