472,958 Members | 2,533 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 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 23792
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.