This is how you can do that using vb.net
As shown above,
Public Sub addWaterMark(ByVal frmFileName As String, ByVal toFileName As String, ByVal pStr As String)
Dim Img As Image
Dim g As Graphics
Dim brsh As Brush
Try
Img = Image.FromFile(frmFileName)
g = Graphics.FromImage(Img)
Dim fontFamily As New FontFamily("Arial")
Dim font As New Font( _
fontFamily, _
60, _
FontStyle.Regular, _
GraphicsUnit.Pixel)
brsh = Brushes.Gray
g.DrawString(pStr, font, Brushes.Gray, 300, 50)
g.DrawImage(Img, 0.0F, 0.0F)
Img.Save(toFileName)
Console.WriteLine("Watermark done")
Catch ex As Exception
Throw New Exception("[addWaterMark01]" & ex.Message)
End Try
End Sub
- First load the image file into an image object
- Create a Graphics object from the image object.
- Then write the message you want, using the font, color and size needed.
- Draw the Graphics back into the image.
- Then save the image to the new file (so you still have your original file.
1 comment:
Sample of the watermark can be found in my other blog.
Post a Comment