SetPixel question

M

Matthew

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
 
K

Ken Tucker [MVP]

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

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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top