wmf files not conveting correctly

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

Guest

Hi,

I am trying to convert a group of wmf files to gif files. Easy you'd think?

I'm using the following code:

Image img = Image.FromFile (this.tbxFilename.Text);
string filename = this.tbxFilename.Text.Replace ("wmf", "gif");
img.Save (filename, ImageFormat.Gif);

When I look at the gif, the background of it is black, where as in the wmf
it is white (or rather transparent).

I tried setting the trasparency via using a bitmap and that didn't work
(also black is one of the colours on the wmv so I didn't want to loose that
colour).

So how can I do this and are there any third party dlls that will work?

Look at http://www.bitbetter.com/samples/Hiking.wmf for an example, as the
background goes black if you try the code.

Any ideas?

Ian
 
You have to set the transparent color of the GIF, as well as the pallette.
The Image class will create a default pallette for the GIF, but you need to
access the pallette to know what color to make transparent.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
Hi,

the images I'm trying to convert have a transparent border, then have a
drawing in black, pinky beige and white on it.

I tried using GetPixel, and it falsely reported an RGB of (0,0,0) for the
border. I.E. black, which is what it comes out in the converted picture. The
trouble is I need black in the finished image and atm both it and the
transparent areas merge into one. Messing with the palette will make no
difference here I think.

I don't mind if the transparent area of the image comes out as transparent
or white, but appearing as black is definitely wrong.

Thanks for your suggestion though, but I can't try anything suggested till
monday now as I am at home.

Regards,

Ian
 
My pleasure. It is important to understand how GIF images do transparency. A
GIF does not support transparency in the same way as many other image
formats. It is an indexed palletted 24-bit (RGB) format, and can only
support one tranparent color, that is, one color that is identified as being
used for a transparent color. In addition, it only supports full
transparency for that one color.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
Back
Top