前端如何把背景图作为参数

前端如何把背景图作为参数,第1张

前端更换背景图,传递到后端
后端接收的参数:>#(转)将自己的转换为xml格式,代码实现:
using System;
using SystemDrawing;
using SystemCollections;
using SystemComponentModel;
using SystemWindowsForms;
using SystemData;
using SystemXml;
using SystemIO;
using SystemDrawingImaging;
namespace xmlfile
{
/// <summary>
/// aboatfile 的摘要说明。
/// </summary>
public class xmlfile
{
public xmlfile()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
//找开一幅XML(XmlTextReader)
public Image openxmlfile(string xmlfilepath)
{
XmlTextReader readxml=new XmlTextReader(xmlfilepath);
int len=641024;
byte[] bytebmp=new byte [len];
while (readxmlRead())
{
if (readxmlNodeType==XmlNodeTypeElement)
{
if (readxmlLocalNameEquals("image"))
{
readxmlReadBase64(bytebmp,0,len);
}
}
}
readxmlClose();
readxml=null;
FileStream streamfile=FileOpenWrite(@"C:Documents and SettingsAdministratorLocal SettingsTempabmp");
streamfileWrite(bytebmp,0,bytebmpLength);
streamfileClose();
streamfile=null;
Image img;
img=SystemDrawingBitmapFromFile(@"C:Documents and SettingsAdministratorLocal SettingsTempabmp");
return img;
}
//保存一幅XML(XmlTextWriter)
public void savexmlfile(string xmlname)
{
FileStream fs=new FileStream(@"C:abmp",FileModeOpen);
string time=DateTimeNowToLongDateString();
int len=4029;
int readByte=0;
byte[] imgdata = new byte[len];
XmlTextWriter xw=new XmlTextWriter(xmlname,SystemTextEncodingUTF8);
xwWriteStartDocument();
xwWriteComment("XML,用base64储存创建于"+time);
xwWriteStartElement("image");
BinaryReader br = new BinaryReader(fs);
do
{
readByte=brRead(imgdata, 0, len);
xwWriteBase64(imgdata, 0, readByte);
}
while (len <= readByte );
xwWriteEndElement();
xwWriteEndDocument();
fsClose();
xwFlush();
xwClose();
FileDelete(@"C:abmp");
}
}
}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/13352359.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-07-20
下一篇 2023-07-20

发表评论

登录后才能评论

评论列表(0条)

保存