Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Transparent PictureBox on BackgroundImage of Form, not BackColor of Form

91 views
Skip to first unread message

Alex Gray

unread,
Jan 22, 2004, 10:34:09 PM1/22/04
to
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-

Bob Powell [MVP]

unread,
Jan 23, 2004, 5:44:03 AM1/23/04
to
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

"Alex Gray" <gra...@netscape.net> wrote in message
news:50347d7a.04012...@posting.google.com...

Alex Gray

unread,
Jan 23, 2004, 9:54:12 AM1/23/04
to
Thank you, Bob! That link you gave me in your reply is excellent.
You saved me quite a lot of time :)
-alex-

"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message news:<OAvMj3Z...@TK2MSFTNGP12.phx.gbl>...

0 new messages