Transparent string : Draw string « 2D Graphics « VB.Net Tutorial






Transparent string
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms

public class AlphaBlending
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class

public class Form1
  Inherits System.Windows.Forms.Form

  Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        Dim g As Graphics = Me.CreateGraphics()
        g.Clear(Me.BackColor)

        Dim curImage As Image = Image.FromFile("yourfile.jpg")
        g.DrawImage(curImage, 0, 0, curImage.Width, curImage.Height) '

        Dim opqPen As New Pen(Color.FromArgb(255, 0, 255, 0), 10)
        Dim transPen As New Pen(Color.FromArgb(128, 0, 255, 0), 10)
        Dim totTransPen As New Pen(Color.FromArgb(40, 0, 255, 0), 10)

        g.DrawLine(opqPen, 10, 10, 200, 10)
        g.DrawLine(transPen, 10, 30, 200, 30)
        g.DrawLine(totTransPen, 10, 50, 200, 50)
        Dim semiTransBrush As New SolidBrush(Color.FromArgb(90, 255, 255, 0))
        g.DrawString("Photo " + ControlChars.Lf + "Date: 04/09/2001", New Font("Verdana", 14), semiTransBrush, New RectangleF(20, 100, 300, 100))

        ' Dispose
        g.Dispose()


  End Sub

  Public Sub New()
   
    MyBase.New()
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(292, 273)
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen

  End Sub

End Class








17.28.Draw string
17.28.1.Print string in 3DPrint string in 3D
17.28.2.Draw string with Brush and Font settingsDraw string with Brush and Font settings
17.28.3.Text outlineText outline
17.28.4.Text ShadowText Shadow
17.28.5.Text ContrastText Contrast
17.28.6.Rotate and Transoform in Text paintingRotate and Transoform in Text painting
17.28.7.Transform TextTransform Text
17.28.8.Use LinearGradientBrush to draw stringUse LinearGradientBrush to draw string
17.28.9.Transparent stringTransparent string