Windows Metafile FAQ

Last Updated: November 23, 1997

Introduction

Here are some answers to frequently asked questions about Windows metafiles. If your question isn't answered here, please send it to support@CompanionSoftware.com for possible inclusion in the next update of this document.

NOTE: External sites are not necessarily endorsed by Companion Software.

Table of Contents

Within this document, you will find information about:

The Basics

What is a graphic?

For the purpose of our discussion, a graphic is any kind of image displayed by a computer. This includes vector graphics and raster graphics.

What is a vector graphic?

A vector graphic is a graphic drawn as lines, polygons and text.

What is a raster graphic?

A raster graphic is a graphic drawn as an array of colored dots.

What is a metafile?

A metafile is a list of commands that can be played back to draw a graphic. Typically, a metafile is made up of commands to draw objects such as lines, polygons and text and commands to control the style of these objects. NOTE: Some people equate metafiles with vector graphics. In most cases this is fine; but, strictly speaking, a metafile can contain any mix of vector and raster graphics. For example, a metafile could contain just one command to display a bitmap! Unless the distinction is important, we will consider a metafile to be a kind of vector graphic in this FAQ.

What is a picture?

In the Windows world, picture is the generic, user-friendly name for a metafile.

What is a bitmap?

A bitmap is a another name for a raster graphic. In Windows, these are typically saved in a BMP file. However other common bitmap formats include PC Paintbrush (PCX), Tagged-Image File Format (TIF), Graphics Interchange Format (GIF) and JPEG.

What are the tradeoffs between vector (metafile) and raster (bitmap) graphics?

In general, vector graphics take longer to display but can be scaled to any size with no degradation. Raster graphics are faster to display but image quality suffers when they are scaled up or down.

Also, there is a tradeoff between the size of a graphic and its complexity. The vector graphic file needed to draw a cross-hatched rectangle full page on a 600-DPI laser printer might be just a few hundred bytes; the comparable raster graphic might be a thousand times bigger! On the other hand, the vector graphic file needed to draw a detailed engineering drawing in a one inch square could be thousands of times bigger than the corresponding raster graphic. So you can't say vector graphics are smaller than raster graphics or vice versa. It depends on the graphic!

What is a Windows metafile (WMF file)?

A Windows metafile is a 16-bit metafile that can be used by Windows 3.x, Windows 95 and Windows NT to display a picture.

What is an enhanced metafile (EMF file)?

An enhanced metafile is a 32-bit metafile that can be used by Windows 95 and Windows NT (not Windows 3) to display a picture. An enhanced metafile can contain a much broader variety of commands than a "regular" Windows metafile. Basically, the enhanced metafile format is a 32-bit super-set of the 16-bit Windows metafile format.

How do Windows clipboard files (CLP files) relate to Windows metafiles?

A CLP file can simultaneously contain a graphic in Picture (WMF), Enhanced metafile (EMF), Bitmap (BMP) and other formats. Some programs (such as Metafile Companion) can extract these files from a CLP file.

What is the difference between CGM and WMF files?

The are both "metafiles", so in a sense they are somewhat equivalent. However, CGM is a older, "platform-independent" metafile format, whereas WMF is a newer, "Windows-only" format. In general, if you're working in the Windows world, stick with WMF files. However, any good conversion program can convert between the two formats.

Converting Between Formats

Can I convert a WMF file to an EMF file?

Yes. But there is no compelling reason to do this that I can think of. As of this writing, most Windows programs support WMF files and don't support EMF files. However, if you're really interested in doing the conversion, keep reading...

If you're a programmer, 32-bit versions of Windows can automatically convert between WMF and EMF files. See the Win32 documentation on the SetWinMetaFileBits() and GetWinMetaFileBits() functions for more details.

Mere mortals can use any number of image conversion programs to convert between formats. For more details, see the Graphics Conversion Software section of the Companion Software Other Helpful Web Sites page.

Can I convert an EMF file to a WMF file?

Yes. The best reason to do this is because, as of this writing, most Windows programs support WMF files and don't support EMF files. But beware! The WMF format is a subset of EMF format so you may loss some information when doing the conversion.

If you're a programmer, 32-bit versions of Windows can automatically convert between WMF and EMF files. See the Win32 documentation on the SetWinMetaFileBits() and GetWinMetaFileBits() functions for more details.

Mere mortals can use any number of image conversion programs to convert between formats. For more details, see the Graphics Conversion Software section of the Companion Software Other Helpful Web Sites page.

How can I convert a WMF file to GIF or JPEG format for use on my Web page?

You can find links to a number of Windows conversion programs at the Graphics Conversion Software section of the Companion Software Other Helpful Web Sites page.

Free utilities to convert from directly from WMF to GIF and JPEG are hard to come by. One simple solution if you have Microsoft Word is to download the free Internet Assistant (http://www.microsoft.com/msword/internet/ia/) add-on to Word. This lets you insert a WMF file onto a page and automatically converts it to a GIF file when you save as an HTML document. Otherwise, you can go the "long" way - use Metafile Companion from Companion Software to copy the WMF file to the clipboard, paste it to Windows Paint, copy the Paint bitmap to the clipboard and paste to a program like LViewPro (http://www.lview.com) that can save it as a GIF file.

As a rule of thumb, use GIF for line art, clip art, etc. and use JPEG for continuous-tone images (photographs).

How can I convert a WMF file to Java source code?

Check out WinMetoJa from Black Dirt Software at http://www.blackdirt.com.

How can I convert a BMP file to a WMF file?

Beware! There are two types of conversions that can be performed and they are very different.

Most conversion programs convert a BMP to a WMF file by simply putting the bitmap in a metafile "shell". The resulting WMF file is still essentially the same original bitmap and gives you no particular advantange over the original BMP file. And this kind of "bitmap disguised as a WMF file" cannot be edited by Metafile Companion. For more details, see the Graphics Conversion Software section of the Companion Software Other Helpful Web Sites page.

However, some conversion programs "auto-trace" or "vectorize" the bitmap converting areas of color to lines and polygons which are then stored in the WMF file. These WMF files can be edited by Metafile Companion. If this is the kind of conversion you want, check out the Hijaak Pro product from IMSI (http://www.imsisoft.com) or the Adobe Illustrator product from Adobe (http://www.adobe.com). Both claim to be able to trace bitmaps.

Another shareware program that can truly vectorize bitmap files is KVEC from KK-Software (http://ourworld.compuserve.com/homepages/kkuhl). KVEC offers a variety of conversion options, outputs many vector formats (not just WMF) and is available on a variety of hardware platforms.

Can a Windows bitmap (BMP) file be transparent in some areas (like a GIF file)?

No. The Windows bitmap format does not support the idea of transparency. However, the Windows metafile format does (see the next question).

Can I convert a Windows bitmap (BMP) file into a transparent Windows metafile (WMF)?

In theory, yes. In practice, we are still looking for a good way to do this.

Basically, there are two approaches you can take:

  1. Put the bitmap in a metafile along with a transparency mask bitmap and use the proper bitmap operations to apply the mask to the bitmap before displaying it on the screen, or
  2. Convert the bitmap to a metafile by "vectorizing" it (as described above) and then delete all objects of the background color.
I don't know of any program that can do approach number 1. You can do approach number 2 by using one of the vectorizing programs described above to convert from bitmap to metafile format. Then use a program like Metafile Companion to select and delete all the background color objects.

Clip Art

Should I get clip art in vector (metafile) or raster (bitmap) format?

The rule of thumb is, get clip art in the form it was created. For most clip art, this means getting it in a vector format (Windows metafile, EPS file, etc.). In vector format, clip art can be scaled to any size you want without loss of quality. However, if the original graphic was a photograph (continuous-tone image) that was scanned in as a raster graphic (bitmap, BMP, TIFF, PCX, etc.), then get the bitmap format.

Where can I find vector format (WMF) clip art?

A variety of vendors offer clip art in WMF format. A good place to start looking is at the Clip Art section of the Companion Software Other Helpful Web Sites page. You might also want to visit the Companion Software Free Clip Art Gallery.

How can I edit my vector format (WMF) clip art?

Most modern Windows drawing programs (such as Microsoft PowerPoint, Corel Draw, etc.) can import and edit Windows metafiles. However, most have their limitations and idiosyncracies. The one program that was designed just to edit WMF files is Metafile Companion.

Importing and Editing

Why does my metafile "change" in some programs when I import it?
Often, drawing programs import a metafile by reading it and converting each metafile object to the closest corresponding drawing object. No drawing program that I am aware of supports all the possible objects contained in a Windows metafile. And some don't always draw objects the same way Windows does.

Most often drawing programs don't handle things like PolyPolygons (polygons with holes and islands), rotated text, bitmap fill patterns and transparent hatch patterns. This can cause certain "idiosyncracies" to appear when editing some metafiles.

If you want to put your favorite drawing program to the test, use it to open TEST.WMF, and make a small change to one of the objects (to make sure the metafile has really been converted to the drawing program's native format). Then use the Windows Clipboard Viewer to open TEST.CLP and see what the chart should really look like! Are they the same? (They are if you're using Metafile Companion!)

Why do some programs display a metafile properly when it is imported, but then change it when I edit it?

This is related to the previous question. Basically, any Windows program can accurately display a Windows metafile with a few lines of code. They just hand the metafile to Windows and say "display it". So some drawing programs take the following approach with metafiles. Initially, when the metafile is added they display it "as is". But as soon as the user tries to edit (or ungroup) the metafile, then they convert it to their own internal format and that's where the idiosyncracies occur.

Are there any drawing programs that can edit a metafile without changing it?

Metafile Companion from Companion Software is about as close as you come to a "perfect" metafile editor. But even it doesn't support every metafile command.

Internal Structure

Where can I find information about the internal structure of Windows metafiles (WMF files) and enhanced metafiles (EMF files)?

On the Microsoft Developer Network (http://msdn.microsoft.com/developer/) Library CD-ROM. This CD is filled with technical information, sample programs, known bugs and great reference books like Programming Windows 3.1 by Charles Petzold. Unfortunately, none of this information is available online from Microsoft.

Another great resource that is online is the Encyclopedia of Graphics File Formats home page (http://www.ora.com/centers/gff/index.htm) hosted by O'Reilly & Associates (http://www.ora.com) They offer information about the WMF (and EMF) file formats at http://www.ora.com/centers/gff/formats/micmeta/index.htm. You can also purchase the Encyclopedia of Graphics File Formats book with CD-ROM at http://www.ora.com/catalog/gffcd/noframes.html.

Where can I find information about the internal structure of Windows clipboard files (CLP files)?

On the Microsoft Developer Network Library CD-ROM. (Déja vû all over again.)

The Encyclopedia of Graphics File Formats home page (mentioned above) also has information about the CLP file format at http://www.ora.com/centers/gff/formats/micclip/index.htm.

How can I list the records inside a particular metafile?

On the Microsoft Developer Network Library CD-ROM, there are a couple of sample Windows programs called WMFDCODE and EMFDCODE that can display a metafile and list its contents.

Other utilities to list the contents of metafiles can be found at the Metafile Listing Utilities section of the Companion Software Windows Metafile Resource Center.

How can I compare two metafiles to see if they are equivalent?

You could compare two metafiles using the DOS COMP or FC command. However, this doesn't always work. Sometimes, metafiles produce identical output but have random "garbage" bytes in unused portions of the file. Other times they contain a "comment" record that includes the filename or other information that doesn't affect the actual output. So, for example, if you open one WMF file (with a program like Metafile Companion), save it with a new name and then do a "binary" compare of the files, the two files won't compare.

The answer to these problems is to do a "conceptual compare" of the actual metafile records themselves excluding any comments. A simple way to to this is to do a binary compare of the listings of two metafiles.

Utilities to compare the listings of metafiles can be found at the Metafile Compare Utilities section of the Companion Software Windows Metafile Resource Center.