温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:功能很全asp.net图片水印组件源码2.0
当前文件路径:ImageWaterMark/uploadimages.aspx.cs

1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
//该源码下载自www.51aspx.com(51aspx.com) 12
13
namespace PanRoor 14
{ 15
public partial class uploadimages : XMLX 16
{ 17
18
PanRoorImageWaterMark wm = new PanRoorImageWaterMark(); 19
PanRoorImageWaterMark.ImageAlign align; 20
PanRoorImageWaterMark.TextCSS txtcss; 21
22
23
string fpath, ftype, fname,dot; 24
25
protected void Page_Load(object sender, EventArgs e) 26
{ 27
28
} 29
protected void But_upload_Click(object sender, EventArgs e) 30
{ 31
32
fname = fup_img.FileName; 33
fpath = fup_img.PostedFile.FileName; 34
ftype = fup_img.PostedFile.ContentType; 35
string[] type = ftype.Split('/'); 36
string[] fn = fname.Split('.'); 37
dot = "." + fn[1].ToString(); 38
if (type[0].ToString() != "image") 39
{ 40
Response.Write("文件格式错误!"); 41
} 42
else 43
{ 44
string filename = DateTime.Now.ToString("yyyyMMddHHmmssffff"); 45
string pt = Server.MapPath("UploadFiles/") + filename + dot; 46
fup_img.SaveAs(pt); 47
fup_img.Dispose(); 48
wm.SaveWaterMarkImagePath = Server.MapPath(XMLRead("SavePath")); 49
wm.SourceImagePath = pt; 50
wm.MiniatureImagePath = Server.MapPath(XMLRead("MinPath")); 51
52
wm.WaterMarkImagePath = Server.MapPath(XMLRead("PicPath")); 53
54
wm.WaterMarkText = XMLRead("WM_Text"); 55
wm.WaterMarkTextFont = XMLRead("Font"); 56
wm.WaterMarkTextSize =Convert.ToInt32(XMLRead("FontSize")); 57
switch (XMLRead("WM_Location")) 58
{ 59
case "LeftTop": 60
align = PanRoorImageWaterMark.ImageAlign.LeftTop; 61
break; 62
case "LeftBottom": 63
align = PanRoorImageWaterMark.ImageAlign.LeftBottom; 64
break; 65
case "Center": 66
align = PanRoorImageWaterMark.ImageAlign.Center; 67
break; 68
case "RightTop": 69
align = PanRoorImageWaterMark.ImageAlign.RightTop; 70
break; 71
case "RightBottom": 72
align = PanRoorImageWaterMark.ImageAlign.RightBottom; 73
break; 74
case "CenterTop": 75
align = PanRoorImageWaterMark.ImageAlign.CenterTop; 76
break; 77
case "CenterBottom": 78
align = PanRoorImageWaterMark.ImageAlign.CenterBottom; 79
break; 80
case "CenterLeft": 81
align = PanRoorImageWaterMark.ImageAlign.CenterLeft; 82
break; 83
case "CenterRight": 84
align = PanRoorImageWaterMark.ImageAlign.CenterRight; 85
break; 86
87
88
} 89
wm.WaterMarkAlign = align; 90
wm.WaterMarkTextColor = XMLRead("FontColor"); 91
wm.WaterMarkTextShadowColor = XMLRead("FontShadow"); 92
if (XMLRead("FontForm") == "Bold") 93
txtcss = PanRoorImageWaterMark.TextCSS.Bold; 94
else if (XMLRead("FontForm") == "Underline") 95
txtcss = PanRoorImageWaterMark.TextCSS.Underline; 96
else if (XMLRead("FontForm") == "Italic") 97
txtcss = PanRoorImageWaterMark.TextCSS.Italic; 98
else if (XMLRead("FontForm") == "Strikeout") 99
txtcss = PanRoorImageWaterMark.TextCSS.Strikeout; 100
101
wm.WaterMarkTextCSS = txtcss; 102
103
104
if (XMLRead("DelPic") == "true") 105
wm.DelPic = true; 106
else 107
wm.DelPic = false; 108
//51_a_s_p_x.c_o_m 109
110
wm.WaterMarkTransparence = Convert.ToInt32(XMLRead("WM_Transparence")); 111
wm.WaterMarkPlaceX = Convert.ToInt32(XMLRead("PlaceX")); 112
wm.WaterMarkPlaceY = Convert.ToInt32(XMLRead("PlaceY")); 113
wm.WaterMarkImageGroundColor = XMLRead("Grounding"); 114
wm.WaterMarkAngle = Convert.ToInt32(XMLRead("WM_Angle")); 115
116
wm.WaterMarkTextShadowDepthX = Convert.ToInt32(XMLRead("ShadowX")); 117
wm.WaterMarkTextShadowDepthY = Convert.ToInt32(XMLRead("ShadowY")); 118
119
wm.TxTShadowTransparence = Convert.ToInt32(XMLRead("Txtshadowtransparence")); 120
wm.ImageQuality = Convert.ToInt32(XMLRead("PicVal")); 121
PanRoorImageWaterMark.WmGetType pictype; 122
if (XMLRead("NoAndOff") == "false") 123
{ 124
pictype = PanRoorImageWaterMark.WmGetType.None; 125
} 126
else if (XMLRead("PicAndText") == "pic") 127
{ 128
pictype = PanRoorImageWaterMark.WmGetType.Pic; 129
} 130
else 131
{ 132
pictype = PanRoorImageWaterMark.WmGetType.Text; 133
} 134
int wmpicwidth = Convert.ToInt32(XMLRead("ZipWidth")); 135
int wmpicheight = Convert.ToInt32(XMLRead("ZipHeight")); 136
//51_a_s_p_x.c_o_m 137
138
bool mininfo = true; 139
if (XMLRead("Miniature") == "false") 140
mininfo = false; 141
int minwidth = Convert.ToInt32(XMLRead("MinWidth")); 142
int minheight = Convert.ToInt32(XMLRead("MinHeight")); 143
PanRoorImageWaterMark.ConvertEffect effect=PanRoorImageWaterMark.ConvertEffect.None; 144
145
if (XMLRead("Effect") == "Monochrome") 146
effect = PanRoorImageWaterMark.ConvertEffect.Monochrome; 147
else if (XMLRead("Effect") == "Negative") 148
effect = PanRoorImageWaterMark.ConvertEffect.Negative; 149
PanRoorImageWaterMark.ImgMosaic mosaic=PanRoorImageWaterMark.ImgMosaic.OFF; 150
if (XMLRead("Mosaic") == "true") 151
mosaic = PanRoorImageWaterMark.ImgMosaic.ON; 152
153
int mosX = Convert.ToInt32(XMLRead("txtmX")); 154
int mosY = Convert.ToInt32(XMLRead("txtmY")); 155
int mosWidth = Convert.ToInt32(XMLRead("txtmWidth")); 156
int mosHeight = Convert.ToInt32(XMLRead("txtmHeight")); 157
PanRoorImageWaterMark.ImgCut imgcut=PanRoorImageWaterMark.ImgCut.OFF; 158
if (XMLRead("Cut") == "true") 159
imgcut = PanRoorImageWaterMark.ImgCut.ON; 160
161
int cutX = Convert.ToInt32(XMLRead("txtcX")); 162
int cutY = Convert.ToInt32(XMLRead("txtcY")); 163
int cutWidth = Convert.ToInt32(XMLRead("txtcWidth")); 164
int cutHeight = Convert.ToInt32(XMLRead("txtcHeight")); 165
166
wm.GetToWaterMarkImage(pictype, wmpicwidth, wmpicheight, mininfo, minwidth, minheight, effect, mosaic, mosX, mosY, mosWidth,mosHeight, imgcut, cutX, cutY, cutWidth, cutHeight); 167
Label1.Text = "<img src=" + Server.MapPath(XMLRead("SavePath")) + filename+"_s.jpg />"; 168
} 169
170
171
} 172
} 173
}//51a_s_p_x.c_o_m 174





}
}