01.
<%@ Page Language=
"VB"
%>
02.
<%@ Import
Namespace
=
"System.Drawing"
%>
03.
<%@ Import
Namespace
=
"System.Drawing.Imaging"
%>
04.
<%@ Import
Namespace
=
"System.Drawing.Text"
%>
05.
06.
<script runat=
"server"
>
07.
08.
Sub
Page_Load(sender
As
Object
, e
As
EventArgs)
09.
Dim
intWidth,intHeight
As
Integer
10.
Dim
FileName
As
String
11.
intWidth = 400
12.
intHeight = 200
13.
FileName =
"MyImages/Images.png"
14.
15.
Dim
objBitmap
As
Bitmap =
New
Bitmap(intWidth, intHeight)
16.
Dim
objGraphic
As
Graphics = Graphics.FromImage(objBitmap)
17.
18.
objGraphic.FillRectangle(Brushes.Maroon, 0, 0, intWidth, intHeight)
19.
20.
21.
Dim
strText
As
String
=
"The Matrix"
22.
23.
Dim
myFont
As
New
PrivateFontCollection()
24.
myFont.AddFontFile(Server.MapPath(
"MyImages/MLTWNII_.ttf"
))
25.
Dim
thisFont
As
FontFamily = myFont.Families(0)
26.
Dim
objFont
As
New
Font(thisFont, 30, FontStyle.Bold)
27.
28.
Dim
objBrushWrite
As
New
SolidBrush(Color.YellowGreen)
29.
30.
31.
Dim
strFormat
As
New
StringFormat
32.
strFormat.Alignment = StringAlignment.Center
33.
strFormat.LineAlignment = StringAlignment.Center
34.
35.
36.
objGraphic.DrawString(strText, objFont, objBrushWrite,
New
Rectangle(0, 0, intWidth, intHeight),strFormat)
37.
38.
39.
objBitmap.Save(Server.MapPath(FileName), ImageFormat.png)
40.
41.
42.
objGraphic.Dispose()
43.
44.
45.
objBitmap =
Nothing
46.
objGraphic =
Nothing
47.
48.
49.
Me
.imgPicture.ImageURL = FileName
50.
51.
End
Sub
52.
53.
</script>
54.
<html>
55.
<head>
56.
<title>ThaiCreate.Com ASP.NET - Images (System.Drawing)</title>
57.
</head>
58.
<body>
59.
<form id=
"form1"
runat=
"server"
>
60.
<asp:Image id=
"imgPicture"
runat=
"server"
/>
61.
</form>
62.
</body>
63.
</html>
64.
</form>