从字节到位图c#
我想将字节转换为位图这是我的代码这是关于从手机接收图像并上传到远程服务器的代码:sql server:这是实现以下界面的函数:从字节到位图c#,c#,bitmap,C#,Bitmap,我想将字节转换为位图这是我的代码这是关于从手机接收图像并上传到远程服务器的代码:sql server:这是实现以下界面的函数: public wsSQLResult CreateImage(Stream JSONdataStream) { wsSQLResult result = new wsSQLResult(); StreamReader reader = new StreamReader(JSONdataStream); string JSONdata = rea
public wsSQLResult CreateImage(Stream JSONdataStream) {
wsSQLResult result = new wsSQLResult();
StreamReader reader = new StreamReader(JSONdataStream);
string JSONdata = reader.ReadToEnd();
// ..then convert the string into a single "wsCustomer" record.
JavaScriptSerializer jss = new JavaScriptSerializer();
wsClass1 cust = jss.Deserialize<wsClass1>(JSONdata);
if (cust == null)
{
result.message = "Unable to deserialize the JSON data.";
return result;
}
pictureDataContext dc = new pictureDataContext();
fff user = (from p
in dc.fff
where (p.id == cust.getid)
select p).FirstOrDefault();
if (user == null)
{
byte[] toDecodeByte = Convert.FromBase64String(cust.getpic);
UploadDocument( toDecodeByte );
fff newCustomer = new fff()
{
id = cust.getid,
title = cust.gettitle,
picture = toDecodeByte
};
dc.fff.InsertOnSubmit(newCustomer);
dc.SubmitChanges();
result.message = "thanks for regestring you may now login";
return result;
}
result.message = "thanks for regestring you may now logijj";
return result;
}
非常感谢您的帮助。我在本说明中也有一个例外:在上载文档方法中使用(位图bm2=新位图(ms))错误消息是什么?System.Drawing.dll中发生了“System.ArgumentException”类型的异常,但未在用户代码中处理其他信息:参数无效….@Loetn System.Drawing.dll中发生了“System.ArgumentException”类型的异常,但未在用户代码中处理其他信息:参数无效
[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, UriTemplate = "Image", BodyStyle = WebMessageBodyStyle.Wrapped)]
wsSQLResult CreateImage(Stream JSONdataStream);