This is the code
Note that the original image can't be used!
Thanks,
Samuel
Public Shared Sub AddTextToImage(ByVal sImageFilePath As String)
Dim org As Bitmap = Image.FromFile(sImageFilePath)
Dim bm As Bitmap = New Bitmap(org.Width, org.Height) ') '; << Can specify
optional pixel format but defaults to 32bppArgb
Dim g As Graphics = Graphics.FromImage(bm)
g.DrawImage(org, 0, 0, org.Width, org.Height)
Dim objFont As System.Drawing.Font
g.TextRenderingHint = TextRenderingHint.AntiAlias
'//Draw other stuff on g here...
objFont = New Font("Comic Sans MS", 75, FontStyle.Bold)
' Write out the text
g.DrawString("Sold", objFont, Brushes.CornflowerBlue, 28, 100)
org.Dispose()
g.Dispose()
'delete the previous file
IO.File.Delete(sImageFilePath)
bm.Save(sImageFilePath, Imaging.ImageFormat.Jpeg)
bm.Dispose()
End Sub
"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
news:u4**************@TK2MSFTNGP03.phx.gbl...
Addendum:
I forgot to mention the 'Graphics' class, which can be used to draw
another bitmap onto your bitmap using its 'DrawImage' method. A
'Graphics' object for a bitmap can be obtained using 'Graphics.FromImage'.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>