HighTechTalks DotNet Forums  

Set 'Transparent Background Color' On System.Drawing.Image Object?

Dotnet Framework (Drawing) microsoft.public.dotnet.framework.drawing


Discuss Set 'Transparent Background Color' On System.Drawing.Image Object? in the Dotnet Framework (Drawing) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
A_StClaire_@hotmail.com
 
Posts: n/a

Default Set 'Transparent Background Color' On System.Drawing.Image Object? - 12-04-2006 , 06:05 PM







hi,

suppose I have a .gif with a cyan-colored background. I'd like this
..gif to appear as if it had a transparent background. using Visual
Studio 2005, is there any property of the Image object I can set to
facilitate this?

something like...

image.transparentBackgroundColor = System.Drawing.Color.Cyan;

thx


Reply With Quote
  #2  
Old   
Michael C
 
Posts: n/a

Default Re: Set 'Transparent Background Color' On System.Drawing.Image Object? - 12-04-2006 , 10:10 PM






<A_StClaire_ (AT) hotmail (DOT) com> wrote

Quote:
hi,

suppose I have a .gif with a cyan-colored background. I'd like this
.gif to appear as if it had a transparent background. using Visual
Studio 2005, is there any property of the Image object I can set to
facilitate this?

something like...

image.transparentBackgroundColor = System.Drawing.Color.Cyan;
I think you need to create an imageattributes object and call SetColorKey.

Quote:
thx




Reply With Quote
  #3  
Old   
Bob Powell [MVP]
 
Posts: n/a

Default Re: Set 'Transparent Background Color' On System.Drawing.Image Object? - 12-05-2006 , 06:11 AM



If you draw the gif using DrawImage a transparent GIF should be drawn with
the transparency.
You can also load the GIF into a Bitmap object and then use the
MakeTransparent method to select a specific transparent color. The advantage
of this is that you can use several transparent colours by making more than
one transparent. This process isn't reversible though.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.



<A_StClaire_ (AT) hotmail (DOT) com> wrote

Quote:
hi,

suppose I have a .gif with a cyan-colored background. I'd like this
.gif to appear as if it had a transparent background. using Visual
Studio 2005, is there any property of the Image object I can set to
facilitate this?

something like...

image.transparentBackgroundColor = System.Drawing.Color.Cyan;

thx




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.