473,756 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Q: Transparent image on a form

Hi

Can anybody help me with the following? It is driving me crazy!!!

I'm trying to produce a non-rectangular form as follows:

(1) Produce a bitmap e.g. gif, using paint shop pro 5.
(2) The Background color of the bitmap is set to white.
(3) Draw a design on the bitmap in a color other than white.
(4) Create a windows application.
(5) Set the forms background image to be the bitmap created earlier.
(6) Set the transparencyKey of the form to be white i.e. the same as the
background color of the bitmap.
(7) Set the FormBorderStyle to None
(8) Run the application.

I expected just the non-white images but instead I still see the white
background! D'OH!!!

Can anybody tell me what I'm doing wrong?

Here's a link to Microsoft describing the same thing.

Thanks in adavance

Geoff
Nov 21 '05 #1
40 2007
Whoops, sorry, here's the link to Microsoft:

http://msdn.microsoft.com/library/de...ndowsforms.asp

Geoff

"Geoff Jones" <no********@ema il.com> wrote in message
news:41******** *************** @news.dial.pipe x.com...
Hi

Can anybody help me with the following? It is driving me crazy!!!

I'm trying to produce a non-rectangular form as follows:

(1) Produce a bitmap e.g. gif, using paint shop pro 5.
(2) The Background color of the bitmap is set to white.
(3) Draw a design on the bitmap in a color other than white.
(4) Create a windows application.
(5) Set the forms background image to be the bitmap created earlier.
(6) Set the transparencyKey of the form to be white i.e. the same as the
background color of the bitmap.
(7) Set the FormBorderStyle to None
(8) Run the application.

I expected just the non-white images but instead I still see the white
background! D'OH!!!

Can anybody tell me what I'm doing wrong?

Here's a link to Microsoft describing the same thing.

Thanks in adavance

Geoff

Nov 21 '05 #2
"Geoff Jones" <no********@ema il.com> schrieb:
I'm trying to produce a non-rectangular form as follows:

(1) Produce a bitmap e.g. gif, using paint shop pro 5.
(2) The Background color of the bitmap is set to white.
(3) Draw a design on the bitmap in a color other than white.
(4) Create a windows application.
(5) Set the forms background image to be the bitmap created earlier.
(6) Set the transparencyKey of the form to be white i.e. the same as the
background color of the bitmap.
(7) Set the FormBorderStyle to None
(8) Run the application.

I expected just the non-white images but instead I still see the white
background! D'OH!!!


You may want to use regions instead:

Region from Bitmap
<URL:http://www.bobpowell.n et/region_from_bit map.htm>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #3
Hi, I also got this problem before, this following VB code may help:)

Public Sub SetBackgroundBi tmap(ByVal image As Image, ByVal
transparencyCol or As Color)

Me.backgroundIm age = New Bitmap(image)
Width = Me.backgroundIm age .Width
Height = Me.backgroundIm age .Height
Region = BitmapToRegion( Me.backgroundIm age, transparencyCol or)

End Sub
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at>
??????:%2****** **********@tk2m sftngp13.phx.gb l...
"Geoff Jones" <no********@ema il.com> schrieb:
I'm trying to produce a non-rectangular form as follows:

(1) Produce a bitmap e.g. gif, using paint shop pro 5.
(2) The Background color of the bitmap is set to white.
(3) Draw a design on the bitmap in a color other than white.
(4) Create a windows application.
(5) Set the forms background image to be the bitmap created earlier.
(6) Set the transparencyKey of the form to be white i.e. the same as the
background color of the bitmap.
(7) Set the FormBorderStyle to None
(8) Run the application.

I expected just the non-white images but instead I still see the white
background! D'OH!!!


You may want to use regions instead:

Region from Bitmap
<URL:http://www.bobpowell.n et/region_from_bit map.htm>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4
Geoff,

I never understood this questions.

Is it something that you want to resize the picturebox to the size of the
image when that is smaller than the picturebox?

Or something I did in this as my sample in this message?
http://groups-beta.google.com/group/...7cab2e04089f27
Cor

"Geoff Jones" <no********@ema il.com> > Whoops, sorry, here's the link to
Microsoft:

http://msdn.microsoft.com/library/de...ndowsforms.asp

Geoff

"Geoff Jones" <no********@ema il.com> wrote in message
news:41******** *************** @news.dial.pipe x.com...
Hi

Can anybody help me with the following? It is driving me crazy!!!

I'm trying to produce a non-rectangular form as follows:

(1) Produce a bitmap e.g. gif, using paint shop pro 5.
(2) The Background color of the bitmap is set to white.
(3) Draw a design on the bitmap in a color other than white.
(4) Create a windows application.
(5) Set the forms background image to be the bitmap created earlier.
(6) Set the transparencyKey of the form to be white i.e. the same as the
background color of the bitmap.
(7) Set the FormBorderStyle to None
(8) Run the application.

I expected just the non-white images but instead I still see the white
background! D'OH!!!

Can anybody tell me what I'm doing wrong?

Here's a link to Microsoft describing the same thing.

Thanks in adavance

Geoff


Nov 21 '05 #5
Hi Cor

If you follow the instructions in the link I gave earlier, I'd be interested
to see if you have the same problem.

Geoff

"Cor Ligthert" <no************ @planet.nl> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Geoff,

I never understood this questions.

Is it something that you want to resize the picturebox to the size of the
image when that is smaller than the picturebox?

Or something I did in this as my sample in this message?
http://groups-beta.google.com/group/...7cab2e04089f27
Cor

"Geoff Jones" <no********@ema il.com> > Whoops, sorry, here's the link to
Microsoft:

http://msdn.microsoft.com/library/de...ndowsforms.asp

Geoff

"Geoff Jones" <no********@ema il.com> wrote in message
news:41******** *************** @news.dial.pipe x.com...
Hi

Can anybody help me with the following? It is driving me crazy!!!

I'm trying to produce a non-rectangular form as follows:

(1) Produce a bitmap e.g. gif, using paint shop pro 5.
(2) The Background color of the bitmap is set to white.
(3) Draw a design on the bitmap in a color other than white.
(4) Create a windows application.
(5) Set the forms background image to be the bitmap created earlier.
(6) Set the transparencyKey of the form to be white i.e. the same as the
background color of the bitmap.
(7) Set the FormBorderStyle to None
(8) Run the application.

I expected just the non-white images but instead I still see the white
background! D'OH!!!

Can anybody tell me what I'm doing wrong?

Here's a link to Microsoft describing the same thing.

Thanks in adavance

Geoff



Nov 21 '05 #6
Geoff,

I once had the same thing and the problem wasn't in my code but in the
colordepth of my screen (right click desktop/properties/settings) , if I
set it to truecolors(24 bits) the transparencyKey didn't work, if I set it
to heigh colors (16 bit) it does work, maybe this helps you

greetz Peter

"zhang" <kz*****@yahoo. com> wrote in message
news:OA******** ******@TK2MSFTN GP15.phx.gbl...
Hi, I also got this problem before, this following VB code may help:)

Public Sub SetBackgroundBi tmap(ByVal image As Image, ByVal
transparencyCol or As Color)

Me.backgroundIm age = New Bitmap(image)
Width = Me.backgroundIm age .Width
Height = Me.backgroundIm age .Height
Region = BitmapToRegion( Me.backgroundIm age, transparencyCol or)

End Sub
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at>
??????:%2****** **********@tk2m sftngp13.phx.gb l...
"Geoff Jones" <no********@ema il.com> schrieb:
I'm trying to produce a non-rectangular form as follows:

(1) Produce a bitmap e.g. gif, using paint shop pro 5.
(2) The Background color of the bitmap is set to white.
(3) Draw a design on the bitmap in a color other than white.
(4) Create a windows application.
(5) Set the forms background image to be the bitmap created earlier.
(6) Set the transparencyKey of the form to be white i.e. the same as the background color of the bitmap.
(7) Set the FormBorderStyle to None
(8) Run the application.

I expected just the non-white images but instead I still see the white
background! D'OH!!!


You may want to use regions instead:

Region from Bitmap
<URL:http://www.bobpowell.n et/region_from_bit map.htm>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Nov 21 '05 #7
Geoff,

Did you see the message from Peter Proost
Otherwise it works for me.
(Therefore I find this useless this way)

I hope this helps anyway

Cor

"Geoff Jones" <no********@ema il.com>
Hi Cor

If you follow the instructions in the link I gave earlier, I'd be
interested to see if you have the same problem.

Geoff

"Cor Ligthert" <no************ @planet.nl> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Geoff,

I never understood this questions.

Is it something that you want to resize the picturebox to the size of the
image when that is smaller than the picturebox?

Or something I did in this as my sample in this message?
http://groups-beta.google.com/group/...7cab2e04089f27
Cor

"Geoff Jones" <no********@ema il.com> > Whoops, sorry, here's the link to
Microsoft:

http://msdn.microsoft.com/library/de...ndowsforms.asp

Geoff

"Geoff Jones" <no********@ema il.com> wrote in message
news:41******** *************** @news.dial.pipe x.com...
Hi

Can anybody help me with the following? It is driving me crazy!!!

I'm trying to produce a non-rectangular form as follows:

(1) Produce a bitmap e.g. gif, using paint shop pro 5.
(2) The Background color of the bitmap is set to white.
(3) Draw a design on the bitmap in a color other than white.
(4) Create a windows application.
(5) Set the forms background image to be the bitmap created earlier.
(6) Set the transparencyKey of the form to be white i.e. the same as
the background color of the bitmap.
(7) Set the FormBorderStyle to None
(8) Run the application.

I expected just the non-white images but instead I still see the white
background! D'OH!!!

Can anybody tell me what I'm doing wrong?

Here's a link to Microsoft describing the same thing.

Thanks in adavance

Geoff



Nov 21 '05 #8
Hi Cor

With your, and others help (ta Peter), it now works :)

I had to change the display to 16 bit and also re-paint the background of
the image I was using with "White" i.e. I'm not sure it was "true white" in
the initial bitmap.

Great, it now works. HOWEVER, this restriction that it has to be less than
24 bit seems to be less than ideal. I don't know what depth the application
will be on the client machines! Surely there must be an easier way to do
this??? Am I right in assuming that even zhang's idea will not work on a 24
bit for the same reasons?

Geoff

"Cor Ligthert" <no************ @planet.nl> wrote in message
news:Oa******** ******@TK2MSFTN GP12.phx.gbl...
Geoff,

Did you see the message from Peter Proost
Otherwise it works for me.
(Therefore I find this useless this way)

I hope this helps anyway

Cor

"Geoff Jones" <no********@ema il.com>
Hi Cor

If you follow the instructions in the link I gave earlier, I'd be
interested to see if you have the same problem.

Geoff

"Cor Ligthert" <no************ @planet.nl> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Geoff,

I never understood this questions.

Is it something that you want to resize the picturebox to the size of
the image when that is smaller than the picturebox?

Or something I did in this as my sample in this message?
http://groups-beta.google.com/group/...7cab2e04089f27
Cor

"Geoff Jones" <no********@ema il.com> > Whoops, sorry, here's the link to
Microsoft:

http://msdn.microsoft.com/library/de...ndowsforms.asp

Geoff

"Geoff Jones" <no********@ema il.com> wrote in message
news:41******** *************** @news.dial.pipe x.com...
> Hi
>
> Can anybody help me with the following? It is driving me crazy!!!
>
> I'm trying to produce a non-rectangular form as follows:
>
> (1) Produce a bitmap e.g. gif, using paint shop pro 5.
> (2) The Background color of the bitmap is set to white.
> (3) Draw a design on the bitmap in a color other than white.
> (4) Create a windows application.
> (5) Set the forms background image to be the bitmap created earlier.
> (6) Set the transparencyKey of the form to be white i.e. the same as
> the background color of the bitmap.
> (7) Set the FormBorderStyle to None
> (8) Run the application.
>
> I expected just the non-white images but instead I still see the white
> background! D'OH!!!
>
> Can anybody tell me what I'm doing wrong?
>
> Here's a link to Microsoft describing the same thing.
>
> Thanks in adavance
>
> Geoff
>



Nov 21 '05 #9
Geoff,

Did you try my sample?

Cor
Nov 21 '05 #10

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

Similar topics

0
1847
by: Graphics_master | last post by:
Anyone know how to create a transparent splash screen similar to Photoshop, After Effects, or premiere. They have a wonderful transparent look. I realize that I can use the key color property of a form to make colors transparent, but I'm not satisfied with aliased edges. I want full 256 color alpha support. I see that the png format has nice transparent support but the form shows through. Forms don't support a transparent background...
2
33526
by: Alex Gray | last post by:
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");
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...
9
7818
by: don | last post by:
I want to create a transparent form and can write something on it by using Ink. I try to set form.backcolor = color.transparent, but it dosen't accept. And everything will be transprent when i use Opacity. Finally, i try to use transparencykey, but any mouse actions will be transferred to the windows below the transparent area. Any solutions? thx
1
13142
by: Chris Auer | last post by:
I have been banging my head for a couple of hours now. No matter what I do the color that I make transparent is black. Here is the code I am using from MSDN. I have tried bitmaps, jpegs, gifs and new bitmaps created in code, but I cant get any image to go transparent. Thanks if you can help. // Create a Bitmap object from an image file. Bitmap myBitmap = new Bitmap(System.Web.HttpContext.Current.Server.MapPath("resources/img/")
8
10610
by: Grahammer | last post by:
Is it possible to set the background of a usercontrol as transparent? I tried setting the background image of the usercontrol to a transparent GIF, but that caused MAJOR problems. I'm making some controls that aren't rectangular and it won't be pretty if I end up with a grey rectangle behind each one. http://msdn.microsoft.com/library/en-us/vbcon/html/vbtskGivingYourControlTransparentBackground.asp?frame=true
5
2543
by: Tony Clark | last post by:
Hi, I have a bmp that is set in a panel, i want to make the white color in the bmp image transparent so i can see the color of the panel below. How is this done? thanks tony
1
1596
by: Lucile | last post by:
Hi All, I am trying to obtain some sort of a "Model" based on horizontal & vertical lines (like a frame) drawn on a form or on a PictureBox. For frames configuration purposes, I created a white background image; and that works fine. But the "Model" will be used to cut off pieces of a given image with MS Office. I would therefore like that the lines be appearent on the image to be cut; but the the underlying control be transparent (so as...
8
2150
by: MikeB | last post by:
Hi, I created a picturebox with a map as an image. I want to make certain areas on the map clickable hotspots and the way I'm trying to do this is to create a transparent label with a different cursor (hand) and then I code the click_event for that label. However, I cannot make the label transparent, even if I choose the Transparent option for the attribute for the background color of the label. Any ideas or suggestions? Thanks
4
10248
by: Dale | last post by:
I am creating GIF images with transparent backgrounds on-the-fly for a web app and rendering them by using System.Drawing.Image.Save(Response.OutputStream, ImageType.GIF). I am confident that the transparency is working properly because if I save the created image to the local hard disk and then view it in a web page or an image editor, the transparency is correct. I can also view the transparency on-the-fly in a Windows.Forms...
0
9275
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
10034
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...
1
9843
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
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
8713
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
6534
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
5142
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
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
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.