Transparent PictureBox on BackgroundImage of Form, not BackColor of Form

  • Thread starter Thread starter Alex Gray
  • Start date Start date
A

Alex Gray

Hi,
I'm trying to make my PictureBox transparent to the BackgroundImage of
the Form, not the BackColor of the form.

Here's what i have:
---------------------------------------------------
this.BackColor = Color.Wheat;

this.gameBackgroundBMP = new
Bitmap(GetType(),"MyForm.backGround.bmp");
this.BackgroundImage = (System.Drawing.Image)gameBackgroundBMP;

this.foo = new Bitmap(GetType(),"MyForm.combatant.bmp");
System.Drawing.Color backColor = foo.GetPixel(1,1);
this.foo.MakeTransparent(backColor);

this.combatant = new System.Windows.Forms.PictureBox();
this.combatant.Image = (System.Drawing.Image)foo;

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

The problem is that the combatant.bmp *is* transparent, but i see
Color.Wheat, not the this.BackgroundImage.

Am I doing something fundamentally wrong here?
thanks in advance,
-alex-
 
PictureBox will not do true transparency because it clears it's background
using the idiot transparency scheme of Windows Forms. You can create a
control that displays an image very easily. There is an article in the GDI+
FAQ about truly transparent controls that will help you to understand how.



--
Bob Powell [MVP]
C#, System.Drawing

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com
 
Thank you, Bob! That link you gave me in your reply is excellent.
You saved me quite a lot of time :)
-alex-
 
Back
Top