473,394 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Transparent PictureBox on BackgroundImage of Form, not BackColor of Form

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-
Nov 15 '05 #1
2 33490
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" <gr*****@netscape.net> wrote in message
news:50**************************@posting.google.c om...
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-

Nov 15 '05 #2
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:<OA*************@TK2MSFTNGP12.phx.gbl>...
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" <gr*****@netscape.net> wrote in message
news:50**************************@posting.google.c om...
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-

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jaikumar | last post by:
Hi, 1) I have created one windows application, In the main form ( form1) i have added one usercontrol (usercontrol1), In that user control i am drawing one image. 2) In the UserControl1 i am...
2
by: Raj | last post by:
Hi, Anyone has any idea as to how we can make a button or any standard windows control as transparent or semi-trnasparent. How can we do this in C#? Thanks, Rajendra
7
by: Peter Oliphant | last post by:
Using MakeTransparent one can supposedly turn a color used in a Bitmap to transparent. But, it looks to me like all it does it set these pixels to the color BackColor of the Control it's attached...
1
by: active | last post by:
I have a UserControl that contains two pictureboxes. One on top of the other. The top one is smaller then the bottom one. The top one is to be transparent. I want to draw on it and then sometimes...
9
by: SStory | last post by:
I have a picturebox in my About form. would like to have a link to my company website. Wanted the links background to be transparent. It seems that no one knows how to do this. Have asked...
0
by: Gino | last post by:
Hi, I wish to code a control that writes a text over a picturebox and that can be dragged with mouse. Here is what i've actually coded to obtain a similar effect, but as you can see i've...
1
by: Ricardo Furtado | last post by:
in my app i must have several pictureboxes over the others. Some pictureboxes just have a couple of lines or rectangles, and absolutly nothing more but the image is an .BMP. So, my problem is that...
1
by: FredC | last post by:
I'm using VS 2003, C#.Net 2003. I built a simple windows form app. with the following attributes: - has a BackgroundImage set to a jpeg I built a very simple user control that contains a...
8
by: Brian Ward | last post by:
I am looking for a simple way to set the image transparency in a PictureBox. I have a moving PictureBox containing a graphic image .. moving by incrementing its Left property. The background...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.