473,776 Members | 1,568 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 4524
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
1486
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, if possible, a simple example so that I can see the code. Thanks. -- Nathan Sokalski...
6
3655
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 right "case". I have made only some superficial test and it seems to work. Note that the purpose is...
0
9628
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9464
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10289
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10120
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9923
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6722
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5493
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4031
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
2
3622
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.