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;
//该源码下载自www.51aspx.com(51aspx.com)
namespace PanRoor
{
public partial class uploadimages : XMLX
{
PanRoorImageWaterMark wm = new PanRoorImageWaterMark();
PanRoorImageWaterMark.ImageAlign align;
PanRoorImageWaterMark.TextCSS txtcss;
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);
fup_img.Dispose();
wm.SaveWaterMarkImagePath = Server.MapPath(XMLRead("SavePath"));
wm.SourceImagePath = pt;
wm.MiniatureImagePath = Server.MapPath(XMLRead("MinPath"));
wm.WaterMarkImagePath = Server.MapPath(XMLRead("PicPath"));
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("DelPic") == "true")
wm.DelPic = true;
else
wm.DelPic = false;
//51_a_s_p_x.c_o_m
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.WaterMarkTextShadowDepthX = Convert.ToInt32(XMLRead("ShadowX"));
wm.WaterMarkTextShadowDepthY = Convert.ToInt32(XMLRead("ShadowY"));
wm.TxTShadowTransparence = Convert.ToInt32(XMLRead("Txtshadowtransparence"));
wm.ImageQuality = Convert.ToInt32(XMLRead("PicVal"));
PanRoorImageWaterMark.WmGetType pictype;
if (XMLRead("NoAndOff") == "false")
{
pictype = PanRoorImageWaterMark.WmGetType.None;
}
else if (XMLRead("PicAndText") == "pic")
{
pictype = PanRoorImageWaterMark.WmGetType.Pic;
}
else
{
pictype = PanRoorImageWaterMark.WmGetType.Text;
}
int wmpicwidth = Convert.ToInt32(XMLRead("ZipWidth"));
int wmpicheight = Convert.ToInt32(XMLRead("ZipHeight"));
//51_a_s_p_x.c_o_m
bool mininfo = true;
if (XMLRead("Miniature") == "false")
mininfo = false;
int minwidth = Convert.ToInt32(XMLRead("MinWidth"));
int minheight = Convert.ToInt32(XMLRead("MinHeight"));
PanRoorImageWaterMark.ConvertEffect effect=PanRoorImageWaterMark.ConvertEffect.None;
if (XMLRead("Effect") == "Monochrome")
effect = PanRoorImageWaterMark.ConvertEffect.Monochrome;
else if (XMLRead("Effect") == "Negative")
effect = PanRoorImageWaterMark.ConvertEffect.Negative;
PanRoorImageWaterMark.ImgMosaic mosaic=PanRoorImageWaterMark.ImgMosaic.OFF;
if (XMLRead("Mosaic") == "true")
mosaic = PanRoorImageWaterMark.ImgMosaic.ON;
int mosX = Convert.ToInt32(XMLRead("txtmX"));
int mosY = Convert.ToInt32(XMLRead("txtmY"));
int mosWidth = Convert.ToInt32(XMLRead("txtmWidth"));
int mosHeight = Convert.ToInt32(XMLRead("txtmHeight"));
PanRoorImageWaterMark.ImgCut imgcut=PanRoorImageWaterMark.ImgCut.OFF;
if (XMLRead("Cut") == "true")
imgcut = PanRoorImageWaterMark.ImgCut.ON;
int cutX = Convert.ToInt32(XMLRead("txtcX"));
int cutY = Convert.ToInt32(XMLRead("txtcY"));
int cutWidth = Convert.ToInt32(XMLRead("txtcWidth"));
int cutHeight = Convert.ToInt32(XMLRead("txtcHeight"));
wm.GetToWaterMarkImage(pictype, wmpicwidth, wmpicheight, mininfo, minwidth, minheight, effect, mosaic, mosX, mosY, mosWidth,mosHeight, imgcut, cutX, cutY, cutWidth, cutHeight);
Label1.Text = "";
}
}
}
}//51a_s_p_x.c_o_m
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment