473,573 Members | 2,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Transparency, ASP.NET, and GDI+

I am trying to create graphics with GDI+ that include transparency. However,
the transparency never seems to show up, even though my colors have an alpha
value of 0. How can I generate a graphic that is completely transparent in
certain areas (so that the web page background shows through)? I save my
graphics as gif files. I would appreciate, if possible, a simple example so
that I can see the code. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/
Aug 11 '05 #1
20 4496
The only graphics formats that have transparency in HTML are GIF and PNG.
What format are you using?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Everybody picks their nose,
But some people are better at hiding it.

"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:Ot******** ******@TK2MSFTN GP10.phx.gbl...
I am trying to create graphics with GDI+ that include transparency.
However, the transparency never seems to show up, even though my colors
have an alpha value of 0. How can I generate a graphic that is completely
transparent in certain areas (so that the web page background shows
through)? I save my graphics as gif files. I would appreciate, if possible,
a simple example so that I can see the code. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

Aug 11 '05 #2
Like I said in my original message, I am using GIF. The line that I use to
save my image is as follows (testbitmap is the name of my
System.Drawing. Bitmap object):

testbitmap.Save (Server.MapPath ("GDItest.gif") , Imaging.ImageFo rmat.Gif)

--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:eq******** ******@TK2MSFTN GP10.phx.gbl...
The only graphics formats that have transparency in HTML are GIF and PNG.
What format are you using?

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Everybody picks their nose,
But some people are better at hiding it.

"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:Ot******** ******@TK2MSFTN GP10.phx.gbl...
I am trying to create graphics with GDI+ that include transparency.
However, the transparency never seems to show up, even though my colors
have an alpha value of 0. How can I generate a graphic that is completely
transparent in certain areas (so that the web page background shows
through)? I save my graphics as gif files. I would appreciate, if
possible, a simple example so that I can see the code. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/


Aug 12 '05 #3
I think IE don't support transparency.
At least I can say for sure it doesn't support PNG transparency.
It is an issue that should be fixed with IE 7 or could be fixd with Firefox!

"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:On******** ******@TK2MSFTN GP14.phx.gbl...
Like I said in my original message, I am using GIF. The line that I use to
save my image is as follows (testbitmap is the name of my
System.Drawing. Bitmap object):

testbitmap.Save (Server.MapPath ("GDItest.gif") , Imaging.ImageFo rmat.Gif)

--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:eq******** ******@TK2MSFTN GP10.phx.gbl...
The only graphics formats that have transparency in HTML are GIF and PNG.
What format are you using?

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Everybody picks their nose,
But some people are better at hiding it.

"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:Ot******** ******@TK2MSFTN GP10.phx.gbl...
I am trying to create graphics with GDI+ that include transparency.
However, the transparency never seems to show up, even though my colors
have an alpha value of 0. How can I generate a graphic that is completely
transparen t in certain areas (so that the web page background shows
through)? I save my graphics as gif files. I would appreciate, if
possible, a simple example so that I can see the code. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/



Aug 12 '05 #4
I know for sure that IE correctly supports transparency in GIF files because
I have made transparent GIF files using Adobe Photoshop in the past that
worked correctly in IE. What the problem appears to be to me, although I
could be wrong, is that when a new System.Drawing. Bitmap is created in
ASP.NET it automatically gives it a background with an Alpha value of 255
(completely opaque). Because of this, whenever anything is drawn on the
bitmap, it is drawn on top of the opaque background. This means that
anything with an Alpha value of 0 (completely transparent) is not visible.
If this is the case, I think the only solution would be to "erase"
previously drawn pixels (which I do not know of a way to do), including the
background or to have the initial background color have an Alpha value of 0.
This is only a theory, so I could be wrong. A workaround that I have come up
with (but it requires the developer to create an extra file) is to use an
existing image file that is completely transparent in the
System.Drawing. Bitmap constructor. Let me know if you come up with any
ideas. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"Lloyd Dupont" <net.galador@ld > wrote in message
news:ey******** ******@TK2MSFTN GP09.phx.gbl...
I think IE don't support transparency.
At least I can say for sure it doesn't support PNG transparency.
It is an issue that should be fixed with IE 7 or could be fixd with
Firefox!

"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:On******** ******@TK2MSFTN GP14.phx.gbl...
Like I said in my original message, I am using GIF. The line that I use
to save my image is as follows (testbitmap is the name of my
System.Drawing. Bitmap object):

testbitmap.Save (Server.MapPath ("GDItest.gif") , Imaging.ImageFo rmat.Gif)

--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:eq******** ******@TK2MSFTN GP10.phx.gbl...
The only graphics formats that have transparency in HTML are GIF and
PNG. What format are you using?

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Everybody picks their nose,
But some people are better at hiding it.

"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:Ot******** ******@TK2MSFTN GP10.phx.gbl...
I am trying to create graphics with GDI+ that include transparency.
However, the transparency never seems to show up, even though my colors
have an alpha value of 0. How can I generate a graphic that is
completel y transparent in certain areas (so that the web page background
shows through)? I save my graphics as gif files. I would appreciate, if
possible, a simple example so that I can see the code. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/



Aug 12 '05 #5
mmhh...
never really investigate this matter, but I would have guess that maybe you
could do:

Bitmap bmp = new Bitmap(width, height);
bmp.MakeTranspa rent();

or with
bmp.LockBit() you could directly access the bitmap's color pointer
as explained here:
http://msdn.microsoft.com/library/de...rp11152001.asp
Aug 12 '05 #6
Not correct. While IE doesn't support PNG transparency, it has lawys
supported GIF transparency.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Everybody picks their nose,
But some people are better at hiding it.

"Lloyd Dupont" <net.galador@ld > wrote in message
news:ey******** ******@TK2MSFTN GP09.phx.gbl...
I think IE don't support transparency.
At least I can say for sure it doesn't support PNG transparency.
It is an issue that should be fixed with IE 7 or could be fixd with
Firefox!

"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:On******** ******@TK2MSFTN GP14.phx.gbl...
Like I said in my original message, I am using GIF. The line that I use
to save my image is as follows (testbitmap is the name of my
System.Drawing. Bitmap object):

testbitmap.Save (Server.MapPath ("GDItest.gif") , Imaging.ImageFo rmat.Gif)

--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:eq******** ******@TK2MSFTN GP10.phx.gbl...
The only graphics formats that have transparency in HTML are GIF and
PNG. What format are you using?

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Everybody picks their nose,
But some people are better at hiding it.

"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:Ot******** ******@TK2MSFTN GP10.phx.gbl...
I am trying to create graphics with GDI+ that include transparency.
However, the transparency never seems to show up, even though my colors
have an alpha value of 0. How can I generate a graphic that is
completel y transparent in certain areas (so that the web page background
shows through)? I save my graphics as gif files. I would appreciate, if
possible, a simple example so that I can see the code. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/



Aug 12 '05 #7
Hi Nathan,

Sorry, I missed the "gif" reference in your OP.

A GIF image palette can define one color as transparent. I'm not sure how
you're defining the transparent color in your palette, but the following
Microsoft KB article explains how to do it. Note that the article is not
specifically about making a transparent gif, but it covers creating a
palette with a single transparent color, which is encoded as the transparent
color for the GIF:

http://support.microsoft.com/default...;EN-US;Q319061

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Everybody picks their nose,
But some people are better at hiding it.

"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:On******** ******@TK2MSFTN GP14.phx.gbl...
Like I said in my original message, I am using GIF. The line that I use to
save my image is as follows (testbitmap is the name of my
System.Drawing. Bitmap object):

testbitmap.Save (Server.MapPath ("GDItest.gif") , Imaging.ImageFo rmat.Gif)

--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:eq******** ******@TK2MSFTN GP10.phx.gbl...
The only graphics formats that have transparency in HTML are GIF and PNG.
What format are you using?

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Everybody picks their nose,
But some people are better at hiding it.

"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:Ot******** ******@TK2MSFTN GP10.phx.gbl...
I am trying to create graphics with GDI+ that include transparency.
However, the transparency never seems to show up, even though my colors
have an alpha value of 0. How can I generate a graphic that is completely
transparen t in certain areas (so that the web page background shows
through)? I save my graphics as gif files. I would appreciate, if
possible, a simple example so that I can see the code. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/



Aug 12 '05 #8
The MakeTransparent () didn't seem to have any affect, and I'm not sure why
(maybe the example wasn't quite clear enough) but the link you gave didn't
seem very clear to me. I think what I really need is a just a basic example
that just draws a simple shape or two and then adds a transparent area.
Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"Lloyd Dupont" <net.galador@ld > wrote in message
news:OM******** ******@tk2msftn gp13.phx.gbl...
mmhh...
never really investigate this matter, but I would have guess that maybe
you could do:

Bitmap bmp = new Bitmap(width, height);
bmp.MakeTranspa rent();

or with
bmp.LockBit() you could directly access the bitmap's color pointer
as explained here:
http://msdn.microsoft.com/library/de...rp11152001.asp

Aug 12 '05 #9
I looked at the article you mentioned, and it definitely cleared up for me
why I was never getting any transparency, but I am still having trouble
figuring out how to fix the problem. I think what I really need is just a
basic example that just draws a simple shape or two and then adds a
transparent area. (Preferably in VB.NET, but I can usually get enough from
C# that it helps enough to solve my problem) Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi Nathan,

Sorry, I missed the "gif" reference in your OP.

A GIF image palette can define one color as transparent. I'm not sure how
you're defining the transparent color in your palette, but the following
Microsoft KB article explains how to do it. Note that the article is not
specifically about making a transparent gif, but it covers creating a
palette with a single transparent color, which is encoded as the
transparent color for the GIF:

http://support.microsoft.com/default...;EN-US;Q319061

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Everybody picks their nose,
But some people are better at hiding it.

"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:On******** ******@TK2MSFTN GP14.phx.gbl...
Like I said in my original message, I am using GIF. The line that I use
to save my image is as follows (testbitmap is the name of my
System.Drawing. Bitmap object):

testbitmap.Save (Server.MapPath ("GDItest.gif") , Imaging.ImageFo rmat.Gif)

--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:eq******** ******@TK2MSFTN GP10.phx.gbl...
The only graphics formats that have transparency in HTML are GIF and
PNG. What format are you using?

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Everybody picks their nose,
But some people are better at hiding it.

"Nathan Sokalski" <nj********@hot mail.com> wrote in message
news:Ot******** ******@TK2MSFTN GP10.phx.gbl...
I am trying to create graphics with GDI+ that include transparency.
However, the transparency never seems to show up, even though my colors
have an alpha value of 0. How can I generate a graphic that is
completel y transparent in certain areas (so that the web page background
shows through)? I save my graphics as gif files. I would appreciate, if
possible, a simple example so that I can see the code. Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/



Aug 12 '05 #10

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

Similar topics

19
1471
by: Nathan Sokalski | last post by:
I am trying to create graphics with GDI+ that include transparency. However, the transparency never seems to show up, even though my colors have an alpha value of 0. How can I generate a graphic that is completely transparent in certain areas (so that the web page background shows through)? I save my graphics as gif files. I would appreciate,...
6
3645
by: tommaso.gastaldi | last post by:
In a previous post I have been asking about a way to test Alpha Transparency. Bob and Michael have kindly provided some ideas. Here I would like to share the function I have prepared, for the purpose to improve it. Frankly, I am not clear about the exact meaning of some pixel format (max, gdi, etc.) and I hope I have put them under the...
0
7746
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7668
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8179
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7736
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8036
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5556
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3699
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2167
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
999
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.