TransparencyKey is not working when using background images

G

Guest

I created a windows form with a certain image with a white area in order to
get it transparent setting the TransparencyKey to white.

The problem is that when it runs, the white color is not transparent.

The image format is PNG and also I tried with a 24 bit BMP image trying to
avoid noise in it.

When I changed the are color to black and changed the Transparency Key to
the same color, black controls are working fine but not the form area showing
the black area of the image.

Am I doing something wrong?

Thanks,
Edmundo
 
B

Bob Powell [MVP]

G

Guest

Yeah this only works until you try to move the form. It then becomes opague
again. So I figured I would try to put the same call in the move and resize
events of the form. No can do, it blows up with a win32 error "The parameter
was invalid" Anyone know how to do this through API calls. Windows media
player does not seem to have a problem displaying transparent areas, so there
must be a way.
 
G

Guest

Edmindo,

I read the article before posting, and I copied the code verbatum.

Img = Bitmap.FromFile(MyImage)
Img.MakeTransparent(Img.GetPixel(1, 1))
Me.BackgroundImage = Img
Me.TransparencyKey = Img.GetPixel(1, 1)

What I am saying is that as long as the form is stationary, it will be
transparent, but as soon as you move it or resize it, it becomes opague
again. The trasparency is ignored by any redraws of the form. Any idea how
to do it using the windows api?
 
G

Guest

Hi Jan,

I cannot reproduce what you are getting while moving or resizing the form.
I moved the form but I did not get the opaque form as you got it.

I hadn't had to modify any move or resize events.

I cannot understand what is wrong in you app.

Edmundo
 

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