Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim watermarkText As String = "Name"
- Dim watermarkText1 As String = "Nameeeee1111"
- 'Get the file name.
- Dim fileName As String = imagepath
- 'Dim fs As FileStream = File.OpenRead(filepath)
- 'Read the File into a Bitmap.
- Using bmp As New Bitmap(File.OpenRead(filepath))
- Using grp As Graphics = Graphics.FromImage(bmp)
- 'Set the Color of the Watermark text.
- Dim brush As Brush = New SolidBrush(Color.FromArgb(100, Color.Gray))
- 'New SolidBrush(Color.Gray)
- 'Set the Font and its size.
- Dim font As Font = New System.Drawing.Font("Times New Roman", 200, FontStyle.Bold, GraphicsUnit.Pixel)
- Dim font1 As Font = New System.Drawing.Font("Times New Roman", 40, FontStyle.Bold, GraphicsUnit.Pixel)
- 'Determine the size of the Watermark text.
- Dim textSize As New SizeF()
- textSize = grp.MeasureString(watermarkText, font)
- Dim textSize1 As New SizeF()
- textSize1 = grp.MeasureString(watermarkText1, font1)
- 'Position the text and draw it on the image.
- ' Dim position As New Point((bmp.Width / 2), (bmp.Height / 2))
- Dim position As New Point((bmp.Width / 2 - (CInt(textSize.Width) / 2)), (bmp.Height / 2 - (textSize.Height / 2)))
- grp.DrawString(watermarkText, font, brush, position)
- Dim position1 As New Point((bmp.Width / 2 - (CInt(textSize.Width) / 2 - 200)), (bmp.Height / 2 - (textSize.Height / 2 - 200)))
- grp.DrawString(watermarkText1, font1, brush, position1)
- Dim p As String
- p = Server.MapPath("reza" & newpath)
- bmp.Save(p, System.Drawing.Imaging.ImageFormat.Jpeg)
- bmp.Dispose()
- brush.Dispose()
- font.Dispose()
- font1.Dispose()
- grp.Dispose()
- GC.Collect()
- GC.WaitForPendingFinalizers()
- End Using
- End Using
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement