VB - Draw Text on Image

By , 4/14/2008
(1 ratings)
With this function you can draw some text on an image
Imports System.Drawing.Imaging
Imports System.Drawing

Private Sub TextOnImage(ByVal OldImage As String, ByVal NewImage As String, ByVal Text As String, ByVal Format As ImageFormat, ByVal Font As Font, ByVal Color As Color, ByVal Position As Point)
    Dim TmpSize As System.Drawing.Size
    Dim Image As Image = System.Drawing.Image.FromFile(OldImage)
    Dim Brush As New SolidBrush(Color)

    'Read Image Dimensions
    TmpSize.Height = Image.Height
    TmpSize.Width = Image.Width

    'Create a new Bitmap Object
    Dim NewBitmap As New System.Drawing.Bitmap(Image, TmpSize)

    'Create a new Graphic Object
    Dim Graphic As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(NewBitmap)

    'Draw String on Image
    Graphic.DrawString(Text, Font, Brush, Position)

    'Save new Image
    NewBitmap.Save(NewImage, Format)

End Sub
Tagged with image, picture, draw.



Log in, to comment!