using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace PanRoor
{
public partial class uploadimages : XMLX
{
PanRoorImageWaterMark wm = new PanRoorImageWaterMark();
PanRoorImageWaterMark.ImageAlign align;
PanRoorImageWaterMark.TextCSS txtcss;
PanRoorImageWaterMark.ConvertEffect ceff;
string fpath, ftype, fname,dot;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void But_upload_Click(object sender, EventArgs e)
{
fname = fup_img.FileName;
fpath = fup_img.PostedFile.FileName;
ftype = fup_img.PostedFile.ContentType;
string[] type = ftype.Split('/');
string[] fn = fname.Split('.');
dot = "." + fn[1].ToString();
if (type[0].ToString() != "image")
{
Response.Write("文件格式错误!");
}
else
{
string filename = DateTime.Now.ToString("yyyyMMddHHmmssffff");
string pt = Server.MapPath("UploadFiles/") + filename + dot;
fup_img.SaveAs(pt);
wm.SaveWaterMarkImagePath = Server.MapPath(XMLRead("SavePath")) + filename + "_S.jpg";
wm.SourceImagePath = pt;
wm.MiniatureImagePath = Server.MapPath(XMLRead("MinPath")) + filename + "_M.jpg";
wm.MiniatureImageWidth = Convert.ToInt32(XMLRead("MinWidth"));
if (XMLRead("PicAndText") == "pic")
wm.WaterMarkImagePath = Server.MapPath(XMLRead("PicPath"));
else
wm.WaterMarkText = XMLRead("WM_Text");
wm.WaterMarkTextFont = XMLRead("Font");
wm.WaterMarkTextSize =Convert.ToInt32(XMLRead("FontSize"));
switch (XMLRead("WM_Location"))
{
case "LeftTop":
align = PanRoorImageWaterMark.ImageAlign.LeftTop;
break;
case "LeftBottom":
align = PanRoorImageWaterMark.ImageAlign.LeftBottom;
break;
case "Center":
align = PanRoorImageWaterMark.ImageAlign.Center;
break;
case "RightTop":
align = PanRoorImageWaterMark.ImageAlign.RightTop;
break;
case "RightBottom":
align = PanRoorImageWaterMark.ImageAlign.RightBottom;
break;
case "CenterTop":
align = PanRoorImageWaterMark.ImageAlign.CenterTop;
break;
case "CenterBottom":
align = PanRoorImageWaterMark.ImageAlign.CenterBottom;
break;
case "CenterLeft":
align = PanRoorImageWaterMark.ImageAlign.CenterLeft;
break;
case "CenterRight":
align = PanRoorImageWaterMark.ImageAlign.CenterRight;
break;
}
wm.WaterMarkAlign = align;
wm.WaterMarkTextColor = XMLRead("FontColor");
wm.WaterMarkTextShadowColor = XMLRead("FontShadow");
if (XMLRead("FontForm") == "Bold")
txtcss = PanRoorImageWaterMark.TextCSS.Bold;
else if (XMLRead("FontForm") == "Underline")
txtcss = PanRoorImageWaterMark.TextCSS.Underline;
else if (XMLRead("FontForm") == "Italic")
txtcss = PanRoorImageWaterMark.TextCSS.Italic;
else if (XMLRead("FontForm") == "Strikeout")
txtcss = PanRoorImageWaterMark.TextCSS.Strikeout;
wm.WaterMarkTextCSS = txtcss;
if (XMLRead("Effect") == "Negative")
ceff = PanRoorImageWaterMark.ConvertEffect.Negative;
else if (XMLRead("Effect") == "Monochrome")
ceff = PanRoorImageWaterMark.ConvertEffect.Monochrome;
else
ceff = PanRoorImageWaterMark.ConvertEffect.None;
wm.ConverImageEffect = ceff;
wm.WaterMarkTransparence = Convert.ToInt32(XMLRead("WM_Transparence"));
wm.WaterMarkPlaceX = Convert.ToInt32(XMLRead("PlaceX"));
wm.WaterMarkPlaceY = Convert.ToInt32(XMLRead("PlaceY"));
wm.WaterMarkImageGroundColor = XMLRead("Grounding");
wm.WaterMarkAngle = Convert.ToInt32(XMLRead("WM_Angle"));
wm.ImageZipHeight = Convert.ToInt32(XMLRead("ZipHeight"));
wm.WaterMarkTextShadowDepthX = Convert.ToInt32(XMLRead("ShadowX"));
wm.WaterMarkTextShadowDepthY = Convert.ToInt32(XMLRead("ShadowY"));
wm.GetToMiniatureImage();
wm.GetToWaterMarkImage();
Label1.Text = "";
}
}
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment