Convert text to Image in vb.net

Tuesday, July 29, 2008


Imports System.Drawing
Imports System.Drawing.Bitmap
Imports System.Drawing.Graphics
Imports System.Drawing.Drawing2D
Imports System.Drawing.Imaging
Imports System.Drawing.Image


Private Sub a()
Dim Text As String = "Rajiv Ranjan"
Dim FontColor As Color = Color.Red
Dim FileName As String = "Image1"
Dim objBitmap As New Bitmap(Width, Height)
Dim objGraphics As Graphics = Graphics.FromImage(objBitmap)
Dim objColor As Color
Dim objFont As New Font(FontName, FontSize)

Dim objBrushForeColor As New SolidBrush(FontColor)
Dim objBrushBackColor As New SolidBrush(BackColor)

objGraphics.FillRectangle(objBrushBackColor, 0, 0, Width, Height)
objGraphics.DrawString(TextBox1.Text.ToString, objFont, objBrushForeColor, objPoint)
objBitmap.Save(Application.StartupPath & FileName & ".JPG", ImageFormat.Jpeg)

0 comments

Post a Comment