473,702 Members | 2,274 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 33520
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
8308
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
5393
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
3587
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
2300
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
14813
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
1250
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
8782
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
3075
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
10173
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
8739
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
8652
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9234
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
9089
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8940
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7831
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...
0
4412
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
4667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3107
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.