Title | Make translucent text suitable for image watermarking in VB .NET |
Description | This example shows how to make translucent text suitable for image watermarking in VB .NET. |
Keywords | watermark, image, translucent, transparent, opacity, VB.NET |
Categories | Graphics, VB.NET |
|
Private Sub Form1_Load(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles MyBase.Load
Dim bm As Bitmap = picSrc.Image.Clone
Dim gr As Graphics = Graphics.FromImage(bm)
Dim brush1 As Brush
Dim brush2 As Brush
Dim string_format As New StringFormat
string_format.Alignment = StringAlignment.Center
Dim dy As Integer = gr.MeasureString("X", _
Me.Font).Height * 1.2
Dim x As Integer = bm.Width \ 2
Dim y As Integer = 60
For opacity As Integer = 31 To 255 Step 32
brush1 = New SolidBrush(Color.FromArgb(opacity, 0, _
0, 0))
brush2 = New SolidBrush(Color.FromArgb(opacity, _
255, 255, 255))
Dim txt As String = "DRAWN WITH OPACITY " & _
opacity.ToString
gr.DrawString(txt, Me.Font, brush1, x, y, _
string_format)
gr.DrawString(txt, Me.Font, brush2, x + 1, y + 1, _
string_format)
y += dy
Next opacity
picResult.Image = bm
gr.Dispose()
End Sub
|