« Getting accurate font metrics in .NET | Main | Opening a metafile in .NET »

Anatomy of a wmz file

Thanks to several people who helped on this (names not listed so they don't get emails from others).

WordML:
The binData is uuencoded - so first decode it.

Uncompress:
The binary file is a gzip. So ungzip it. Note: this is not a winzip type zip.

The file is now a "placeable" metafile. Interestingly, all documentation about this by Microsoft says this is not a supported format and that Microsoft does not use it. The file structure is:

WmfPlaceableFileHeader; // in GdiPlusMetaHeader.h
METAHEADER; // in WinGDI.h
[] METARECORD; // in WinGDI.h

When WmfPlaceableFileHeader is read, you have 4 shorts that are the image bounding box and then a word (called inches) that is the twips/inch for the image. If you use the box to get the width & height, then width/inches is the width of the image in inches and height/inches is the height.

This means that a width of 1.0 means the image is 1" across. This says nothing about the number of pixels because a wmf is by definition resolution independent so your dpi settings determine the pixel size.

Rtf:
This is not uuencoded and is not zipped. It is an ascii listing of the binary. So all chars are 0-9,A-F. Each pair of characters becomes a byte of data. In other words the string "01F4" becomes 2 bytes 0x01,0xF4.

This is then a metafile. Not a placeable metafile, but a plain old METAFILE with the standard 18 byte header where the start is 01000900. The size of this metafile must be pulled from the \sp tags before the wmf in the rtf file.

As with xml, your DPI settings, along with the \sp values, are used to determine the pixel size of the final image. And as with the xml case, the documentation for a wmf file is spotty.

Do you find this useful? If so please check out Windward Reports.

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d8341c6cc353ef00d8355667ef69e2

Listed below are links to weblogs that reference Anatomy of a wmz file:

Comments

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment