我想将字节转换为位图这里是我的代码,代码是关于从移动设备接收图像并上传到远程服务器:sql server:这是实现以下界面的函数:
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;
}
这里是界面请任何帮助和thnkx很多:
[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, UriTemplate = "Image", BodyStyle = WebMessageBodyStyle.Wrapped)]
wsSQLResult CreateImage(Stream JSONdataStream);
我很乐意为你提供帮助。