web 2.0

ASP.NET(vb.net) & Write Text to Image

ASP.NET(vb.net) & Write Text to Image - The in this tutorial, you’ll learn and example scripts how to Write text to image using by ASP.NET scripts.

ShotDev Focus:
- ASP.NET(vb.net) & Write Text to Image

Example

AspNetWriteTextImages1.aspx

<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Page Language="VB" %>
<script runat="server">

Sub Page_Load(sender As Object, e As EventArgs)
Dim intWidth,intHeight As Integer
Dim FileName As String
intWidth =     400
intHeight = 200
FileName = "MyImages/Images.png"

Dim objBitmap As Bitmap = New Bitmap(intWidth, intHeight)
Dim objGraphic As Graphics = Graphics.FromImage(objBitmap)
'*** Create Images ***'
objGraphic.FillRectangle(Brushes.Maroon, 0, 0, intWidth, intHeight)

'*** Write Text ***'
Dim strText As String = "ยินดีต้อนรับ Welcome To www.ShotDev.Com" '*** String ***'
Dim objFont As New Font("Tahoma", 10,FontStyle.Italic) '*** Font Style ***'
Dim objPoint As New PointF(5, intHeight - 20) '*** Point ***'
Dim objBrushWrite As New SolidBrush(Color.YellowGreen) '*** Font Color ***'

objGraphic.DrawString(strText, objFont, objBrushWrite, objPoint)

'*** Save As ***'
objBitmap.Save(Server.MapPath(FileName), ImageFormat.png)

'*** Close ***'
objGraphic.Dispose()

'*** Nothing ***'
objBitmap = Nothing
objGraphic = Nothing

'*** View Images ***'
Me.imgPicture.ImageURL = FileName

End Sub

</script>
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Image id="imgPicture" runat="server" />
</form>
</body>
</html>

Screenshot

ASP.NET(vb.net) & Write Text to Image
.
.
.
Download this script.
Download
.
.
.
ASP.NET(vb.net) & Write Text to Image - The in this tutorial, you’ll learn and example scripts how to Write text to image (Text Center align) using by ASP.NET scripts.

ShotDev Focus:
- ASP.NET(vb.net) & Write Text to Image

Example

AspNetWriteTextImages2.aspx

<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Page Language="VB" %>
<script runat="server">

Sub Page_Load(sender As Object, e As EventArgs)
Dim intWidth,intHeight As Integer
Dim FileName As String
intWidth =     400
intHeight = 200
FileName = "MyImages/Images.png"

Dim objBitmap As Bitmap = New Bitmap(intWidth, intHeight)
Dim objGraphic As Graphics = Graphics.FromImage(objBitmap)
'*** Create Images ***'
objGraphic.FillRectangle(Brushes.Maroon, 0, 0, intWidth, intHeight)

'*** Write Text ***'
Dim strText As String = "ยินดีต้อนรับ Welcome To www.ShotDev.Com" '*** String ***'
Dim objFont As New Font("Tahoma", 12,FontStyle.Bold) '*** Font Style ***'
Dim objBrushWrite As New SolidBrush(Color.YellowGreen) '*** Font Color ***'

'*** Text Align ***'
Dim strFormat As New StringFormat
strFormat.Alignment = StringAlignment.Center  '*** .Near (Left) , .Far (Right) ***'
strFormat.LineAlignment = StringAlignment.Center '*** .Near (Top) , .Far (Down) ***'

'*** DrawString ***'
objGraphic.DrawString(strText, objFont, objBrushWrite, New Rectangle(0, 0, intWidth, intHeight),strFormat)

'*** Save As ***'
objBitmap.Save(Server.MapPath(FileName), ImageFormat.png)

'*** Close ***'
objGraphic.Dispose()

'*** Nothing ***'
objBitmap = Nothing
objGraphic = Nothing

'*** View Images ***'
Me.imgPicture.ImageURL = FileName

End Sub

</script>
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Image id="imgPicture" runat="server" />
</form>
</body>
</html>

Screenshot

ASP.NET(vb.net) & Write Text to Image
.
.
.
Download this script.
Download
.
.
.
ASP.NET(vb.net) & Write Text to Image - The in this tutorial, you’ll learn and example scripts how to Write text to image (AddFontFile) using by ASP.NET scripts.

ShotDev Focus:
- ASP.NET(vb.net) & Write Text to Image

Example

AspNetWriteTextImages3.aspx

<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Drawing.Text" %>
<%@ Page Language="VB" %>
<script runat="server">

Sub Page_Load(sender As Object, e As EventArgs)
Dim intWidth,intHeight As Integer
Dim FileName As String
intWidth =     400
intHeight = 200
FileName = "MyImages/Images.png"

Dim objBitmap As Bitmap = New Bitmap(intWidth, intHeight)
Dim objGraphic As Graphics = Graphics.FromImage(objBitmap)
'*** Create Images ***'
objGraphic.FillRectangle(Brushes.Maroon, 0, 0, intWidth, intHeight)

'*** Write Text ***'
Dim strText As String = "The Matrix" '*** String ***'
'*** Font **'
Dim myFont As New PrivateFontCollection()
myFont.AddFontFile(Server.MapPath("MyImages/MLTWNII_.ttf"))
Dim thisFont As FontFamily = myFont.Families(0)
Dim objFont As New Font(thisFont, 30, FontStyle.Bold) '*** Font Style ***'

Dim objBrushWrite As New SolidBrush(Color.YellowGreen) '*** Font Color ***'

'*** Text Align ***'
Dim strFormat As New StringFormat
strFormat.Alignment = StringAlignment.Center  '*** .Near (Left) , .Far (Right) ***'
strFormat.LineAlignment = StringAlignment.Center '*** .Near (Top) , .Far (Down) ***'

'*** DrawString ***'
objGraphic.DrawString(strText, objFont, objBrushWrite, New Rectangle(0, 0, intWidth, intHeight),strFormat)

'*** Save As ***'
objBitmap.Save(Server.MapPath(FileName), ImageFormat.png)

'*** Close ***'
objGraphic.Dispose()

'*** Nothing ***'
objBitmap = Nothing
objGraphic = Nothing

'*** View Images ***'
Me.imgPicture.ImageURL = FileName

End Sub

</script>
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Image id="imgPicture" runat="server" />
</form>
</body>
</html>

Screenshot

ASP.NET(vb.net) & Write Text to Image
.
.
.
Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (No Ratings Yet)
Loading ... Loading ...

One Response to “ASP.NET(vb.net) & Write Text to Image”

  1. 1browsing…

Leave a Reply

You must be logged in to post a comment.