01.
<%@ Page Language=
"C#"
Debug=
"true"
%>
02.
<%@ Import Namespace=
"System.Drawing"
%>
03.
<%@ Import Namespace=
"System.Drawing.Imaging"
%>
04.
05.
<script runat=
"server"
>
06.
07.
void
Page_Load(
object
sender, EventArgs e)
08.
{
09.
10.
string
OpenFileName;
11.
string
NewFileName;
12.
OpenFileName =
"MyImages/Mygirl.jpg"
;
13.
NewFileName =
"MyImages/New_Mygirl.jpg"
;
14.
15.
Bitmap objBitmap =
new
System.Drawing.Bitmap(Server.MapPath(OpenFileName));
16.
Graphics objGraphic = Graphics.FromImage(objBitmap);
17.
18.
19.
20.
string
strText =
"CopyRight 2009 (www.ThaiCreate.Com)"
;
21.
22.
Font objFont =
new
Font(
"Tahoma"
, 8);
23.
24.
SolidBrush objBrushWrite =
new
SolidBrush(Color.Red);
25.
26.
27.
28.
StringFormat strFormat =
new
StringFormat();
29.
strFormat.Alignment = StringAlignment.Far;
30.
31.
strFormat.LineAlignment = StringAlignment.Far;
32.
33.
34.
35.
objGraphic.DrawString(strText, objFont, objBrushWrite,
new
Rectangle(0, 0, objBitmap.Width, objBitmap.Height), strFormat);
36.
37.
38.
objBitmap.Save(Server.MapPath(NewFileName), ImageFormat.Jpeg);
39.
40.
41.
objGraphic.Dispose();
42.
43.
44.
objBitmap =
null
;
45.
objGraphic =
null
;
46.
47.
48.
this
.imgPicture.ImageUrl = NewFileName;
49.
50.
}
51.
52.
</script>
53.
<html>
54.
<head>
55.
<title>ThaiCreate.Com ASP.NET - Images (System.Drawing)</title>
56.
</head>
57.
<body>
58.
<form id=
"form1"
runat=
"server"
>
59.
<asp:Image id=
"imgPicture"
runat=
"server"
/>
60.
</form>
61.
</body>
62.
</html>
63.
</form>