繁体   English   中英

使用Xamarin形式将图像转换为字节以用于iPhone应用程序

[英]Convert image to byte for iphone application using xamarin forms

我想将图像转换为字节以供服务器上传。 所以,我用下面的代码抛出错误。 有人可以帮我吗?

错误:“对类型'system.componentmodel.typeconverter'的引用声称它是定义的组装系统,但找不到。”

public static byte[] imgToByteConverter(System.Drawing.Image inImg)
{
    ImageConverter imgCon = new ImageConverter();   
    return (byte[])imgCon.ConvertTo(inImg, typeof(byte[]));        
}

Xamarin表单图像与System.Drawing.Image不同。 System.Drawing.Image是W32类,在Xamarin中不存在。 您不能将XF图像转换为byte []。 相反,您需要引用用于创建映像的任何资源(文件,流,URL等),然后使用该资源创建byte []。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM