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

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 23866
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
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...
0
by: eruess | last post by:
Here's the scenario: I've got a whole bunch (for the sake of argument, let's say thousands) of different little 32x14 .png files that act as buttons all over a very large website. Each button...
2
by: Jax | last post by:
So far i've not had much luck with this method. Bitmap.MakeTransparent(someColor); Makes the transparent colour either a non-transparent black (.bmp, jpg or .gif) or silver (.png) i've tried...
0
by: Josch | last post by:
I have here a specific problem with ASP.NET in C#. I want to convert an Icon (System.Drawing.Icon icon) to a GIF-Image. First, my attempt was converting the icon to a Bitmap: Bitmap bmp =...
7
by: Martin | last post by:
I'm using the code show below (in VB.Net 2003) to create an image. I want to save this image to a .PNG file such that when I subsequently display it as part of a web page, the background of the...
2
by: Mark Denardo | last post by:
Hi, I need some expert GDI+ person to help me with my RoundOffImage Function: What I'm trying to do is take in an image, crop off the edges around an ellipse region I set up, and then return the...
4
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...
5
by: WT | last post by:
I am trying to crete a gif file with transparent backcolor on the fly but it seems that GDI refuses to do this. I am using samples from Bob Powell but it doesn't seem to work. First create a...
8
by: Hrungdak | last post by:
Hi all I am new here and i hope i do not make any mistakes with this question. I try to change a GIF-File that contains transparency. The problem lies within the following code: ' Open a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...

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.