transparent image in memory

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How would I create a 1x1 pixel transparent gif in memory? I don't want to
load it from an existing file.

Thanks,
Todd
 
Hi there,

For some strange reason I could not get the Framework to save a GIF with
transparency,but unforatunely the GIF encoder does not have any setable
parameters so I couldn't do much more. (FW 1.0)

I could on the other hand save the picture as a PNG with transparency.
Making a bitmap object is a piece of cake,

Dim pop As New Bitmap(1, 1, Imaging.PixelFormat.Format32bppArgb)
Call pop.Save("c:\pop.png", Imaging.ImageFormat.Png)

The above will make a 1 x 1 bitmap with an alpha channel, the default
colour appears to be alpha already so there is no need to set it, but if you
want to make a pixel completely transparent do the following

Call pop.SetPixel(0, 0, Color.FromArgb(0, 0, 0, 0))

The first value (Alpha) ranges from 0 (Transparent) to 1 (Opaque). I
hope that this helps!

Nick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top