dotnet-Snippets.com
Snippets: 61 | Registered User: 61 | Visitors online: 2
Main Menu

Home
Random Snippet
FAQs
Contact Us
Imprint
RSS Feeds

Rss All languages
Rss C#
Rss VB.NET
Rss C++
Rss J#
Rss ASP.NET
Google Ads

Sri Lanka .NET 
                Forum Member
Draw Text on Image

Author: Tim Hartwig
Programming Language: VB.NET Rating:
not yet rated

Views: 10320

Description:

With this function you can draw some text on an image



Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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)

    Graphic.Dispose()
    NewBitmap.Dispose()
End Sub

This Snippets could be interesting for you:

Poor Excellent
1 2 3 4 5 6 7 8 9 10
Sign in to vote for this snippet.

Comments:
(Please log in to wrtite an comment.)