Mega Code Archive

 
Categories / VB.Net Tutorial / 2D Graphics
 

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