469,576 Members | 1,681 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,576 developers. It's quick & easy.

Transparent GIF using Bitmap.Save()

When I create a System.Drawing.Bitmap and save it as ImageType.GIF, how can I
set the transparency so that the background is transparent.

In my application, the Bitmap that I am working with has several transparent
GIFs drawn on it and the transparency of each of them works within the
bitmap, but the bitmap overall gets saved with a black background.

Any help is greatly appreciated.
--
Dale Preston
MCAD C#
MCSE, MCDBA
Oct 19 '06 #1
5 23208
I guest this will help:
http://www.bobpowell.net/giftransparency.htm

Regards,

Bela Istok

"Dale" <da******@nospam.nospamwrote in message
news:75**********************************@microsof t.com...
When I create a System.Drawing.Bitmap and save it as ImageType.GIF, how
can I
set the transparency so that the background is transparent.

In my application, the Bitmap that I am working with has several
transparent
GIFs drawn on it and the transparency of each of them works within the
bitmap, but the bitmap overall gets saved with a black background.

Any help is greatly appreciated.
--
Dale Preston
MCAD C#
MCSE, MCDBA
Oct 19 '06 #2
Thanks, Bela! That's exactly what I need.

I had read a Microsoft KB article on the same topic, KB #319061, but that
was so confusing I couldn't make head nor tails of it.

Thanks to you and to Bob Powell!
--
Dale Preston
MCAD C#
MCSE, MCDBA
"Bela Istok" wrote:
I guest this will help:
http://www.bobpowell.net/giftransparency.htm

Regards,

Bela Istok

"Dale" <da******@nospam.nospamwrote in message
news:75**********************************@microsof t.com...
When I create a System.Drawing.Bitmap and save it as ImageType.GIF, how
can I
set the transparency so that the background is transparent.

In my application, the Bitmap that I am working with has several
transparent
GIFs drawn on it and the transparency of each of them works within the
bitmap, but the bitmap overall gets saved with a black background.

Any help is greatly appreciated.
--
Dale Preston
MCAD C#
MCSE, MCDBA
Oct 19 '06 #3
In .NET v2 you should be able to do the following:

//Load an Image
Bitmap img = new Bitmap("c:\\image3.bmp");

//Get the color of the first pixel and make that color transparent
Color c = img.GetPixel(0, 0);
img.MakeTransparent(c);

then just save the image...

Kelly S. Elias
Webmaster
DevDistrict - C# Code Library
http://devdistrict.com
Dale wrote:
Thanks, Bela! That's exactly what I need.

I had read a Microsoft KB article on the same topic, KB #319061, but that
was so confusing I couldn't make head nor tails of it.

Thanks to you and to Bob Powell!
--
Dale Preston
MCAD C#
MCSE, MCDBA
"Bela Istok" wrote:
I guest this will help:
http://www.bobpowell.net/giftransparency.htm

Regards,

Bela Istok

"Dale" <da******@nospam.nospamwrote in message
news:75**********************************@microsof t.com...
When I create a System.Drawing.Bitmap and save it as ImageType.GIF, how
can I
set the transparency so that the background is transparent.
>
In my application, the Bitmap that I am working with has several
transparent
GIFs drawn on it and the transparency of each of them works within the
bitmap, but the bitmap overall gets saved with a black background.
>
Any help is greatly appreciated.
>
>
--
Dale Preston
MCAD C#
MCSE, MCDBA
Oct 20 '06 #4
Hi Kelly,

Just for clarification, the MakeTransparent method is not only supported in
..NET framework 2.0, but also 1.1 and 1.0.

http://msdn2.microsoft.com/en-us/library/8517ckds.aspx

Kevin Yu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Oct 20 '06 #5
Thanks for the suggestion. I would like to try MakeTransparent in the
future. I couldn't use it in this case because the Graphics object was
corrupting the palette by duplicating the transparent color in the palette.
That meant I still had to create a new image, add my corrected palette, and
then do a pixel by pixel copy to move the original pixels into the new image
as suggested in Bob Powell's article in order to fix issues caused by that
duplicate palette entry.

I sure wish I could have gotten away with something as simple as
MakeTransparent.

Thanks again, Cryptik and Kevin.

Dale
--
Dale Preston
MCAD C#
MCSE, MCDBA
"Cryptik" wrote:
In .NET v2 you should be able to do the following:

//Load an Image
Bitmap img = new Bitmap("c:\\image3.bmp");

//Get the color of the first pixel and make that color transparent
Color c = img.GetPixel(0, 0);
img.MakeTransparent(c);

then just save the image...

Kelly S. Elias
Webmaster
DevDistrict - C# Code Library
http://devdistrict.com
Dale wrote:
Thanks, Bela! That's exactly what I need.

I had read a Microsoft KB article on the same topic, KB #319061, but that
was so confusing I couldn't make head nor tails of it.

Thanks to you and to Bob Powell!
--
Dale Preston
MCAD C#
MCSE, MCDBA
"Bela Istok" wrote:
I guest this will help:
http://www.bobpowell.net/giftransparency.htm
>
Regards,
>
Bela Istok
>
"Dale" <da******@nospam.nospamwrote in message
news:75**********************************@microsof t.com...
When I create a System.Drawing.Bitmap and save it as ImageType.GIF, how
can I
set the transparency so that the background is transparent.

In my application, the Bitmap that I am working with has several
transparent
GIFs drawn on it and the transparency of each of them works within the
bitmap, but the bitmap overall gets saved with a black background.

Any help is greatly appreciated.


--
Dale Preston
MCAD C#
MCSE, MCDBA
>

Oct 21 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by eruess | last post: by
reply views Thread by Josch | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.