Connecting Tech Pros Worldwide Forums | Help | Site Map

SetPixel question

Matthew
Guest
 
Posts: n/a
#1: Nov 21 '05
I have put the following in my Form1_Load event:

Dim Img As Bitmap = New Bitmap(1, 1)
Img.SetPixel(0, 0, Color.Green)
BackgroundImage = Img
TransparencyKey = Img.GetPixel(0, 0)

This makes the background green. It should make the background transparent.

If you comment out the second line, it actually works properly. However, I
need the image to be green.

Any ideas?

Matthew



Ken Tucker [MVP]
Guest
 
Posts: n/a
#2: Nov 21 '05

re: SetPixel question


Hi,

Why not try something like this

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

Me.TransparencyKey = Color.Green

e.Graphics.FillRectangle(Brushes.Green, Me.ClientRectangle)

End Sub



Ken

-------------------------------

"Matthew" <turn.deletethis@alltel.net> wrote in message
news:u2Dm9oJtEHA.220@TK2MSFTNGP15.phx.gbl...
I have put the following in my Form1_Load event:

Dim Img As Bitmap = New Bitmap(1, 1)
Img.SetPixel(0, 0, Color.Green)
BackgroundImage = Img
TransparencyKey = Img.GetPixel(0, 0)

This makes the background green. It should make the background transparent.

If you comment out the second line, it actually works properly. However, I
need the image to be green.

Any ideas?

Matthew



Matthew
Guest
 
Posts: n/a
#3: Nov 21 '05

re: SetPixel question


> Me.TransparencyKey = Color.Green[color=blue]
> e.Graphics.FillRectangle(Brushes.Green, Me.ClientRectangle)[/color]

That's perfect.
Thanks Ken!

Matthew


Closed Thread


Similar Visual Basic .NET bytes