【问题标题】:Convert image to byte array on Windows Phone 7 No System.Drawing Dll any other way?在 Windows Phone 7 上将图像转换为字节数组 No System.Drawing Dll 还有其他方式吗?
【发布时间】:2012-05-10 06:26:22
【问题描述】:
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 那样

谢谢

【问题讨论】:

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


【解决方案1】:

首先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();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多