|VC++ 6.0 ebook chapter index|
Metafiles are to vector graphics as bitmaps are to raster graphics. While bitmaps generally originate from real-world images, metafiles are constructed by humans, generally helped out by computer programs. A metafile consists of a series of binary records that correspond to graphics function calls, generally to draw straight lines, curves, filled areas, and text.
"Paint" programs create bitmaps; "draw" programs create metafiles. In a well-designed drawing program, you can easily "grab" a particular graphical object (such as a line) and move it somewhere else. That's because all the individual components of the picture are stored as separate records. In a paint program, such feats are not possible—you're generally restricted to removing or inserting rectangular chunks of the bitmap.
Because the metafile describes an image in terms of graphical drawing commands, the metafile image can be scaled without loss of resolution. Bitmaps don't work that way: If you display a bitmap at twice the size, you don't get twice the resolution. The bits in the bitmap are simply replicated horizontally and vertically.
A metafile can be converted to a bitmap, but with some loss of information: the graphical objects that make up the metafile are no longer separate and become blended together in one big image. Converting bitmaps to metafiles is a much more difficult job, usually restricted to very simple images and requiring a lot of processing power to analyze edges and outlines. However, a metafile can contain a command to draw a bitmap.
Metafiles are used most often for sharing pictures among programs through the clipboard, although they can also exist on disk as clip art. Because metafiles describe a picture as a collection of graphics function calls, they generally take up much less space and are more device independent than bitmaps.
Microsoft Windows supports two metafile formats and two sets of functions to support them. I'll first discuss the metafile functions supported since Windows 1.0, and still supported under the current 32-bit versions of Windows, and then discuss the "enhanced metafile" developed for the 32-bit versions of Windows. The enhanced metafiles have several improvements over the old metafile format and should be used whenever possible.