Dont forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
Thanks for the link - I already had tried to wade through that - but there must be an easier way - All I want is a brand new totally transparent gif of a specific size. I am not trying to change an existing file. This can't be but a few lines of code. I'm
obviously new to GDI+, but why doesn't graphics.clear(color.transparent) work as expected?
I believe when you do graphics.clear() you are essentially adding a new 'layer' to the image on top of the existing layers. So by adding graphics.clear(color.transparent) its as if its adding a transparent later on top. If you replace transparent with red
i believe that will be added on top. So this is why its probably not working how you would expect.
gretchen
Member
60 Points
119 Posts
Transparent Image?
Dec 05, 2007 11:30 AM|LINK
I'm trying to draw a totally transparent image - 200 pixels wide and 500 pixels high - all I get is a black image.
Dim ChartBitMap As Bitmap = New Bitmap(ChartWidth, ChartHeight)Dim ChartGraphics As Graphics = Graphics.FromImage(ChartBitMap)ChartGraphics.Clear(Color.Transparent)
ChartBitMap.Save(
"C://Test_transparent.gif", System.Drawing.Imaging.ImageFormat.Gif)Thanks,
Gretchen
transparency
robert.weste...
Contributor
2352 Points
399 Posts
Re: Transparent Image?
Dec 05, 2007 12:00 PM|LINK
Have a look at http://www.bobpowell.net/giftransparency.htm, where you'll find an explanation of how to do it.
Dont forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
gretchen
Member
60 Points
119 Posts
Re: Transparent Image?
Dec 05, 2007 12:30 PM|LINK
Hi Robert!
Thanks for the link - I already had tried to wade through that - but there must be an easier way - All I want is a brand new totally transparent gif of a specific size. I am not trying to change an existing file. This can't be but a few lines of code. I'm obviously new to GDI+, but why doesn't graphics.clear(color.transparent) work as expected?
Thanks,
Gretchen
CurtWRC
Participant
1131 Points
1026 Posts
Re: Transparent Image?
Dec 05, 2007 03:50 PM|LINK
Hi Gretchen,
I believe when you do graphics.clear() you are essentially adding a new 'layer' to the image on top of the existing layers. So by adding graphics.clear(color.transparent) its as if its adding a transparent later on top. If you replace transparent with red i believe that will be added on top. So this is why its probably not working how you would expect.
gretchen
Member
60 Points
119 Posts
Re: Transparent Image?
Dec 05, 2007 04:05 PM|LINK
Thanks Curt - that makes sense. Does this mean there is no way to 'easily' produce a transparent gif?
kgolding
Member
18 Points
8 Posts
Re: Transparent Image?
Feb 19, 2009 03:47 PM|LINK
I think what you have will work fine, just make the follwing change:
Change this: Dim ChartBitMap As Bitmap = New Bitmap(ChartWidth, ChartHeight)
TO: Dim ChartBitMap As Bitmap = New Bitmap(ChartWidth, ChartHeight, PixelFormat.Format32bppArgb)