473,320 Members | 1,691 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,320 software developers and data experts.

image color transparency

Hi,
I need to load a picture on a button but I'd like to set white color
tranansparency (not to show white color). How can I do it? I tried to
load a masked color GIF file but VS 2002 could not load it.

thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
10 10738
Why don't you just create your gif with a transparency layer and put the
transparent gif on the button? That should work.

- Peder -
newbie_csharp wrote:
Hi,
I need to load a picture on a button but I'd like to set white color
tranansparency (not to show white color). How can I do it? I tried to
load a masked color GIF file but VS 2002 could not load it.

thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #2
"newbie_csharp" <an*******@devdex.com> wrote:
I need to load a picture on a button but I'd like to set white color
tranansparency (not to show white color). How can I do it? I tried to
load a masked color GIF file but VS 2002 could not load it.


Does the Bitmap class's 'MakeTransparent' method do what you need?

E.g.

Bitmap bmp = new Bitmap("MyGifFile.gif");
bmp.MakeTransparent(Color.White);
btn.BackgroundImage = bmp;

--
Ian Griffiths - http://www.interact-sw.co.uk/iangblog/
DevelopMentor - http://www.develop.com/
Nov 16 '05 #3
Hi Peder,
I opened a gif file in Corel and saved it with setting white color
transparency; but in Visual Studio I could not open it. it didn't let me to
open those kind of Gif files. I am using VS 2002 right now.
thanks,
Hamid

"Peder Y" <1@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Why don't you just create your gif with a transparency layer and put the
transparent gif on the button? That should work.

- Peder -
newbie_csharp wrote:
Hi,
I need to load a picture on a button but I'd like to set white color
tranansparency (not to show white color). How can I do it? I tried to
load a masked color GIF file but VS 2002 could not load it.

thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #4
Hi Ian,

thanks a lot. that worked. but should I do the same for all my buttons? is
there any simpler way for doing this? but this answer helped me learn about
Bitmap :) thanks Ian!

Hamid

"Ian Griffiths [C# MVP]" <ia*************@nospam.nospam> wrote in message
news:Ok**************@TK2MSFTNGP10.phx.gbl...
"newbie_csharp" <an*******@devdex.com> wrote:
I need to load a picture on a button but I'd like to set white color
tranansparency (not to show white color). How can I do it? I tried to
load a masked color GIF file but VS 2002 could not load it.


Does the Bitmap class's 'MakeTransparent' method do what you need?

E.g.

Bitmap bmp = new Bitmap("MyGifFile.gif");
bmp.MakeTransparent(Color.White);
btn.BackgroundImage = bmp;

--
Ian Griffiths - http://www.interact-sw.co.uk/iangblog/
DevelopMentor - http://www.develop.com/

Nov 16 '05 #5
When you say you're looking for something simpler, do you mean you want
simpler code? (I didn't think 3 lines of code was all that bad...) Or do
you want to do without code at all, and instead go via the designer?

I think I'd need to understand a little more about what you're doing before
I can suggest what might make it simpler.

--
Ian Griffiths - http://www.interact-sw.co.uk/iangblog/
DevelopMentor - http://www.develop.com/

"Adine" wrote:

thanks a lot. that worked. but should I do the same for all my buttons? is
there any simpler way for doing this? but this answer helped me learn
about Bitmap :) thanks Ian!

"Ian Griffiths [C# MVP]" wrote:
"newbie_csharp" <an*******@devdex.com> wrote:
I need to load a picture on a button but I'd like to set white color
tranansparency (not to show white color). How can I do it? I tried to
load a masked color GIF file but VS 2002 could not load it.


Does the Bitmap class's 'MakeTransparent' method do what you need?

E.g.

Bitmap bmp = new Bitmap("MyGifFile.gif");
bmp.MakeTransparent(Color.White);
btn.BackgroundImage = bmp;

--
Ian Griffiths - http://www.interact-sw.co.uk/iangblog/
DevelopMentor - http://www.develop.com/


Nov 16 '05 #6
I meant via designer. because if I have 20 buttons on the form, then I need
to add 20 x 3 lines in the program. that would be nice if VS had a property
beside image property to set the transparency.

Thanks again

"Ian Griffiths [C# MVP]" <ia*************@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
When you say you're looking for something simpler, do you mean you want
simpler code? (I didn't think 3 lines of code was all that bad...) Or do
you want to do without code at all, and instead go via the designer?

I think I'd need to understand a little more about what you're doing
before I can suggest what might make it simpler.

--
Ian Griffiths - http://www.interact-sw.co.uk/iangblog/
DevelopMentor - http://www.develop.com/

"Adine" wrote:

thanks a lot. that worked. but should I do the same for all my buttons?
is there any simpler way for doing this? but this answer helped me learn
about Bitmap :) thanks Ian!

"Ian Griffiths [C# MVP]" wrote:
"newbie_csharp" <an*******@devdex.com> wrote:
I need to load a picture on a button but I'd like to set white color
tranansparency (not to show white color). How can I do it? I tried to
load a masked color GIF file but VS 2002 could not load it.

Does the Bitmap class's 'MakeTransparent' method do what you need?

E.g.

Bitmap bmp = new Bitmap("MyGifFile.gif");
bmp.MakeTransparent(Color.White);
btn.BackgroundImage = bmp;

--
Ian Griffiths - http://www.interact-sw.co.uk/iangblog/
DevelopMentor - http://www.develop.com/



Nov 16 '05 #7
Something you could try is writing a little program to load all your button
GIF files, doing the MakeTransparent thing and then saving them back out as
PNG files, and then loading them in via the designer.

I don't know if that would actually work by the way, I'm just hypothesizing
that it might - I'd try it with one file on its own first... Something like
this:

Bitmap bmp = new Bitmap("MyGifFile.gif");
bmp.MakeTransparent(Color.White);
bmp.Save("MyFile.png", Imageformat.Png);

See if loading that PNG file in with the designer now works as intended.
(I'm suggesting this because PNG supports a full alpha channel.)

If that seems to work, then just convert all the GIFs to PNGs using code
like the above as a once-off process, and then use the PNGs as the things
you load into the designer.
--
Ian Griffiths - http://www.interact-sw.co.uk/iangblog/
DevelopMentor - http://www.develop.com/

"Adine" wrote:
I meant via designer. because if I have 20 buttons on the form, then I need
to add 20 x 3 lines in the program. that would be nice if VS had a property
beside image property to set the transparency.

Nov 16 '05 #8
perfect! PNG type was the answer. that's great. now I don't need to load the
image all the time and set the transparency.

Thank you so much, Ian.

"Ian Griffiths [C# MVP]" <ia*************@nospam.nospam> wrote in message
news:e1**************@TK2MSFTNGP15.phx.gbl...
Something you could try is writing a little program to load all your
button GIF files, doing the MakeTransparent thing and then saving them
back out as PNG files, and then loading them in via the designer.

I don't know if that would actually work by the way, I'm just
hypothesizing that it might - I'd try it with one file on its own first...
Something like this:

Bitmap bmp = new Bitmap("MyGifFile.gif");
bmp.MakeTransparent(Color.White);
bmp.Save("MyFile.png", Imageformat.Png);

See if loading that PNG file in with the designer now works as intended.
(I'm suggesting this because PNG supports a full alpha channel.)

If that seems to work, then just convert all the GIFs to PNGs using code
like the above as a once-off process, and then use the PNGs as the things
you load into the designer.
--
Ian Griffiths - http://www.interact-sw.co.uk/iangblog/
DevelopMentor - http://www.develop.com/

"Adine" wrote:
I meant via designer. because if I have 20 buttons on the form, then I
need to add 20 x 3 lines in the program. that would be nice if VS had a
property beside image property to set the transparency.


Nov 16 '05 #9
Hi Adine!

I see Ian solved your problem. Glad you worked it out. However, I've
never had problems using transparent gif's. It could be that VS don't
support the gif format Corel produces. My Photoshop exports Gif89a,
which is the ancient gif standard. This seems to work fine. Good luck!

- Peder -
Adine wrote:
Hi Peder,
I opened a gif file in Corel and saved it with setting white color
transparency; but in Visual Studio I could not open it. it didn't let me to
open those kind of Gif files. I am using VS 2002 right now.
thanks,
Hamid

"Peder Y" <1@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Why don't you just create your gif with a transparency layer and put the
transparent gif on the button? That should work.

- Peder -
newbie_csharp wrote:
Hi,
I need to load a picture on a button but I'd like to set white color
tranansparency (not to show white color). How can I do it? I tried to
load a masked color GIF file but VS 2002 could not load it.

thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 16 '05 #10
Hi Adine!

I see Ian solved your problem. Glad you worked it out. However, I've
never had problems using transparent gif's. It could be that VS don't
support the gif format Corel produces. My Photoshop exports Gif89a,
which is the ancient gif standard. This seems to work fine. Good luck!

- Peder -
Adine wrote:
Hi Peder,
I opened a gif file in Corel and saved it with setting white color
transparency; but in Visual Studio I could not open it. it didn't let me to
open those kind of Gif files. I am using VS 2002 right now.
thanks,
Hamid

"Peder Y" <1@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Why don't you just create your gif with a transparency layer and put the
transparent gif on the button? That should work.

- Peder -
newbie_csharp wrote:
Hi,
I need to load a picture on a button but I'd like to set white color
tranansparency (not to show white color). How can I do it? I tried to
load a masked color GIF file but VS 2002 could not load it.

thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 16 '05 #11

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

Similar topics

5
by: unknown | last post by:
I am trying to place a company logo on a form but try as I will I can not get the transparent parts to stay transparent. Is this even possible? If so what file format does my picture need to be...
10
by: Woody Splawn | last post by:
I have a button that I would like to put on a form, actually a panel on a form. The problem is that it's transparency color is magenta and I can not find a way to make the button look right. The...
2
by: sympatico | last post by:
im trying to read an image(*.bmp) from file and then color the black pixels in it to the color i want using argb. Below is the code of what im trying to do but this gives me an error "setPixel is...
3
by: Martijn Mulder | last post by:
When I populate a ToolStrip with ToolStripButtons with a .png-image on it, will Windows understand the transparency of the .png file?
4
by: ttest | last post by:
Hello, I'm working on an image processing project using the Python Imaging Library along with numpy. Right now, I'm trying to build a speedy script for converting whole images between the RGB...
1
by: Marge | last post by:
I imported a project from VB6 ok except for the fact that a couple of gif files which have transparent backgounds nolonger display correctly. On VB6 the images were loaded into their own image...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.