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
|