1
if (FileUpload1.PostedFile.ContentType.ToLower().IndexOf("image") < 0)
2
{
3
FunctionUtility.JavaScriptHelper.Alert("上传的文件格式不正确!");
4
return;
5
}
6![](/Images/OutliningIndicators/None.gif)
7
Stream oStream = FileUpload1.PostedFile.InputStream;
8
System.Drawing.Image oImage = System.Drawing.Image.FromStream(oStream);
9![](/Images/OutliningIndicators/None.gif)
10
if(CheckBox1.Checked)
11
{
12
//加文字水印
13
Graphics g = Graphics.FromImage(oImage);
14
g.DrawImage(oImage, 0, 0, oImage.Width, oImage.Height);
15
Font f = new Font("Verdana",15);
16
Brush b = new SolidBrush(Color.White);
17
g.DrawString("http://www.itwealth.cn制作", f, b, 0, oImage.Height - 30);
18
g.Dispose();
19
}
20
else
21
{
22
//加图片水印
23
System.Drawing.Image copyImage = System.Drawing.Image.FromFile(Server.MapPath("/DesignImages/Images/SYT/Admin.jpg"));
24
Graphics g = Graphics.FromImage(oImage);
25
g.DrawImage(copyImage, new Rectangle(oImage.Width - copyImage.Width, oImage.Height - copyImage.Height, copyImage.Width, copyImage.Height), 0, 0, copyImage.Width, copyImage.Height, GraphicsUnit.Pixel);
26
g.Dispose();
27
}
28![](/Images/OutliningIndicators/None.gif)
29
string setFileName = FunctionUtility.FileHelper.GetDateTimeFileName() + ".jpg";
30
string oFullName = Server.MapPath("/DesignImages/Images/SYT/" + setFileName);
31
oImage.Save(oFullName, System.Drawing.Imaging.ImageFormat.Jpeg);
32
oImage.Dispose();
33![](/Images/OutliningIndicators/None.gif)
34
Image1.Visible = true;
35
Image1.ImageUrl = "/DesignImages/Images/SYT/" + setFileName;
36
FunctionUtility.JavaScriptHelper.Alert("水印加载成功!");
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
3
![](/Images/OutliningIndicators/InBlock.gif)
4
![](/Images/OutliningIndicators/InBlock.gif)
5
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
6
![](/Images/OutliningIndicators/None.gif)
7
![](/Images/OutliningIndicators/None.gif)
8
![](/Images/OutliningIndicators/None.gif)
9
![](/Images/OutliningIndicators/None.gif)
10
![](/Images/OutliningIndicators/None.gif)
11
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
12
![](/Images/OutliningIndicators/InBlock.gif)
13
![](/Images/OutliningIndicators/InBlock.gif)
14
![](/Images/OutliningIndicators/InBlock.gif)
15
![](/Images/OutliningIndicators/InBlock.gif)
16
![](/Images/OutliningIndicators/InBlock.gif)
17
![](/Images/OutliningIndicators/InBlock.gif)
18
![](/Images/OutliningIndicators/InBlock.gif)
19
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
20
![](/Images/OutliningIndicators/None.gif)
21
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
22
![](/Images/OutliningIndicators/InBlock.gif)
23
![](/Images/OutliningIndicators/InBlock.gif)
24
![](/Images/OutliningIndicators/InBlock.gif)
25
![](/Images/OutliningIndicators/InBlock.gif)
26
![](/Images/OutliningIndicators/InBlock.gif)
27
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
28
![](/Images/OutliningIndicators/None.gif)
29
![](/Images/OutliningIndicators/None.gif)
30
![](/Images/OutliningIndicators/None.gif)
31
![](/Images/OutliningIndicators/None.gif)
32
![](/Images/OutliningIndicators/None.gif)
33
![](/Images/OutliningIndicators/None.gif)
34
![](/Images/OutliningIndicators/None.gif)
35
![](/Images/OutliningIndicators/None.gif)
36
![](/Images/OutliningIndicators/None.gif)