Sorry for the delay in replying, I have been away.
(attached). The function simply creates a white image with some green text.
"Michael Phillips, Jr." wrote:
> I believe that I am a little confused as to what you wish
> to accomplish.
>
> 1) For a .gif file with a transparent color,
> MakeTransparent is used to let the system know
> what color is transparent in the .gif for purposes of
> drawing the .gif to a background with some other
> color. The transparent portion of the .gif will be
> replaced with the color of the background.
> 2) In this case, SetColorKey does the same thing.
> It sets the color-key to the transparent portion of the
> .gif. When the image is drawn the transparent portion
> of the image is replaced with the background that
> you draw to.
>
> In either case, you either hard code the color or you
> use GetPixel to get the color at a point such as x=0,y=0
> for the transparent color.
>
> If the .gif background shows up as black in a web page,
> then the .gif's color table may not have been encoded
> correctly by gdiplus's .gif image encoder.
>
> I have had problems in this regard using the .gif encoder
> that comes with gdiplus. I don't believe it follows the
> ..gif specification correctly!
>
> It creates a local color table with the transparency index set
> in the .gif header but fails to read and use this index when
> the image is reloaded. I believe it should create a Global
> Color Table with the transparency index and background
> color set per the specification.
>
> If you wish to change the transparent color, you must remap
> the colors in the palette to account for the new transparent color.
>
> Bob Powell has an excellent article on how to accomplish this.
> You may read it here:
>
http://www.bobpowell.net/giftransparency.htm >
> His method works and the image will be correctly displayed
> either in a form or a web page.
>
> "Steve Bugden" <SteveBugden@discussions.microsoft.com> wrote in message
> news:4746317E-BE11-447E-B6A5-E2D43F64EB1C@microsoft.com...
> > Hi Michael,
> >
> > Thanks for your reply, from your code, I tried the following:
> >
> > 'Create the image
> > bmpImage = New Bitmap(50, 50)
> > grfgraphics = Graphics.FromImage(bmpImage)
> >
> > Dim imageAttr As New ImageAttributes
> > Dim transColor As New Color
> > transColor = Color.White
> > imageAttr.SetColorKey(transColor, transColor, ColorAdjustType.Default)
> > Dim objrectangle As New Rectangle(0, 0, bmpImage.Width, bmpImage.Height)
> > 'Draw the .gif file blending with the background
> > grfgraphics.DrawImage(bmpImage, objrectangle, 0, 0, bmpImage.Width,
> > bmpImage.Height, GraphicsUnit.Pixel, imageAttr)
> > bmpImage.Save("C:\\temp\temp.gif")
> >
> > But the image is black when displayed in an html page. Have I missed
> > something?
> >
> > Best Regards,
> >
> > Steve
> >
> > "Michael Phillips, Jr." wrote:
> >
> >> I suggest that you create an ImageAtributes object
> >> and use the method SetColorKey to set the color-key
> >> to the transparent color of the .gif file.
> >>
> >> Then use DrawImage.
> >>
> >> Example:
> >> Dim imageAttr As New ImageAttributes()
> >> Dim transColor As Color
> >> myBitmap.GetPixel(0,0,transColor) ' Color.White
> >> imageAttr.SetColorKey(transColor,transColor,ColorAdjustType.Default)
> >> Dim rect as New Rectangle(0,0,myBitmap.Width,myBitmap.Height)
> >> ' Draw the .gif file blending with the background
> >> e.Graphics.DrawImage(myBitmap, rect, 0, 0,
> >> myBitmap.Width,myBitmap.Height, _
> >> GraphicsUnit.Pixel, imageAttr)
> >>
> >> This will allow you to draw against any background.
> >> The transparent portion of the .gif file will be replaced
> >> with the background that you draw against.
> >>
> >>
> >> "Steve Bugden" <SteveBugden@discussions.microsoft.com> wrote in message
> >> news:1F260D2B-3CFD-44D4-B8DC-73A04B3F7897@microsoft.com...
> >> > Hi,
> >> >
> >> > From your above suggestion I tried the following in the paint event of
> >> > a
> >> > form:
> >> >
> >> > '******************************
> >> > Dim myBitmap As Bitmap
> >> > Dim strFIleName As String = "C:\temp\someimage.gif"
> >> >
> >> > ' Make the image transparent and save it
> >> > myBitmap = New Bitmap(strFIleName)
> >> > myBitmap.MakeTransparent(Color.White)
> >> > myBitmap.Save(strFIleName)
> >> >
> >> > 'Get the image again
> >> > myBitmap = New Bitmap(strFIleName)
> >> >
> >> > ' Draw the transparent bitmap to the screen.
> >> > e.Graphics.DrawImage(myBitmap, myBitmap.Width, 0, myBitmap.Width, _
> >> > myBitmap.Height)
> >> > '******************************
> >> >
> >> > THis works fine on the windows form but when I insert the image into an
> >> > html
> >> > page the background is black.
> >> >
> >> > Hope no one minds me tagging on to this existing question/answer.
> >> >
> >> > Can anyone tell me what I'm doing wrong?
> >> >
> >> > Many thanks,
> >> >
> >> > Steve
> >> >
> >> > "Bob Powell [MVP]" wrote:
> >> >
> >> >> To modify the GIF's transparent colour see the GDI+ FAQ article.
> >> >>
> >> >> To make it transparent after you've loaded it in a Bitmap see
> >> >> Bitmap.MakeTransparent.
> >> >>
> >> >> --
> >> >> Bob Powell [MVP]
> >> >> Visual C#, System.Drawing