473,769 Members | 5,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.gameBackgr oundBMP = new
Bitmap(GetType( ),"MyForm.backG round.bmp");
this.Background Image = (System.Drawing .Image)gameBack groundBMP;

this.foo = new Bitmap(GetType( ),"MyForm.comba tant.bmp");
System.Drawing. Color backColor = foo.GetPixel(1, 1);
this.foo.MakeTr ansparent(backC olor);

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

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

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

Am I doing something fundamentally wrong here?
thanks in advance,
-alex-
Nov 15 '05 #1
2 33528
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*****@netsca pe.net> wrote in message
news:50******** *************** ***@posting.goo gle.com...
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.gameBackgr oundBMP = new
Bitmap(GetType( ),"MyForm.backG round.bmp");
this.Background Image = (System.Drawing .Image)gameBack groundBMP;

this.foo = new Bitmap(GetType( ),"MyForm.comba tant.bmp");
System.Drawing. Color backColor = foo.GetPixel(1, 1);
this.foo.MakeTr ansparent(backC olor);

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

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

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

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@_spamkille r_bobpowell.net > wrote in message news:<OA******* ******@TK2MSFTN GP12.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*****@netsca pe.net> wrote in message
news:50******** *************** ***@posting.goo gle.com...
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.gameBackgr oundBMP = new
Bitmap(GetType( ),"MyForm.backG round.bmp");
this.Background Image = (System.Drawing .Image)gameBack groundBMP;

this.foo = new Bitmap(GetType( ),"MyForm.comba tant.bmp");
System.Drawing. Color backColor = foo.GetPixel(1, 1);
this.foo.MakeTr ansparent(backC olor);

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

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

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

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
8312
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 showing one transparent form (form3) when ever user preseed left mouse button. 3) The form3 has one transparent user control (usercontrol2) that paints circles. That measn the circles will show on top the usercontrol1 image. 4) The form3 border style...
2
5396
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
3589
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 to. Thus, when I set White to the transparent color of a Bitmap stored in the Image of a PictureBox and placed the PictureBox on a Form which has a BackColor of black, it turned the white pixels of the bitmap image to black, but these black pixels...
1
2302
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 clear it and sometimes copy the drawing to the bottom picturebox image or BackgroundImage. Just to see if it would work I set the Background color of the top one to transparent but, rather then seeing the bottom box in the transparent one I...
9
14820
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 many times. VB help says that transparent is possible with a background image but not above a control. So how can I provide a link (URL) that is clickable, but transparent, over the picturebox in my about box?
0
1253
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 serious problems with trasparence Create new project and add a button in the form and then insert a background image to the form itself.
1
8791
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 i need to see whats beind those pictureboxes and at the same time showing, the lines and rectangles that exist on the pictureboxes that are at the top. Because i just can't copy the image to the other picturebox (because i'll have to be able to...
1
3083
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 picture box set to an icon. The UserControl constructor sets SetStyle( ControlStyles.SupportTransparentBackColor, true); this.BackColor = Color.Transparent; The control does nothing except display the icon.
8
10176
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 however shows white as the PictureBox moves but I want it to be transparent. The PictureBox BackColor is set to Transparent .. but no affect. I have used PhotoShop to make the image background transparent .. again no affect. If I make the image a...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8870
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7408
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.