View Full Version : [help] VB.net 2008


^DraKe^
14th Jul '08 Mon, 06:19
Guys meron ba kaung sample ng dynamic opacity ng picture box sa 2008 di kc gumagana ung nsa 2005 ko eh. Thanks in advance ^_^!

hmx_ryan
15th Jul '08 Tue, 08:34
:unsure: Hindi ko pa natatry itong Dynamic Opacity... I hope this codes could still help you

Display transparent Images in picture box


Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim g As Graphics = e.Graphics

' Create an Image from a file
Dim curImage As Image = Image.FromFile("image.jpg")

' Draw image
g.DrawImage(curImage, 0, 0, curImage.Width, curImage.Height)

' Create pens with different opacity
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)

' Draw graphics object using transparent pens
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(60, 0, 255, 0))
g.FillRectangle(semiTransBrush, 20, 100, 200, 100)

End Sub



This one is like Masking... It will make any defined color transparent. Concept of Masking


Private Function Transparent(ByVal image As System.Drawing.Bitmap)
image.MakeTransparent(Color.FromArgb(0, 255, 0, 255)) '(Alpha, Red, Green, Blue) 255,0,255 = PINK
Transparent = image
End Function

'Call it like this:
Picturebox.Image = Transparent(My.Resources.ImageNameYouUse)