They specifically mention that the HeaderSize field should have the
value 9. But while I try reading it I am getting some other value.
Don't know why it is so. Similarly all the other fields are
inconsistent with respect to the documentation mentioned in the web
page. Here is the code I've used.
cout << "Opening file...\n";
//char* filepath = "C:\\Program Files\\Microsoft Office\\Office12\
if( !file.Open( _T("C:\\Program Files\\Microsoft Office\\Office12\
\BITMAPS\\STYLES\\GLOBE.WMF"), CFile::modeRead, &fexp) )
cout << "Reading information...\n" ;
WMFHEAD* head = new _WindowsMetaHeader;
//reading 18 bytes
file.Read((void*) head, 18);
cout << "head->FileType : " << head->FileType << '\n' <<
"head->HeaderSize : " << head->HeaderSize << '\n' <<
"head->Version : " << head->Version << '\n' <<
"head->FileSize : " << head->FileSize << '\n' <<
"head->NumOfObjects : " << head->NumOfObjects << '\n' <<
"head->MaxRecordSize : " << head->MaxRecordSize << '\n' <<
"head->NoParameters : " << head->NoParameters << '\n';
cout <<"Closing file...\n";
Hope someone can guide me on this...
Could it be that your wmf file has a portability header prepended?
See the "Porting WMF Files Between Applications" of your link for more
Here is what I got as output:
pmh->Key = 2596720087
pmh->Handle = 0
pmh->Left = -1458
pmh->Top = -666
pmh->Right = 1458
pmh->Bottom = 1344
pmh->Inch = 576
pmh->Reserved = 0
pmh->Checksum = 21131
Not sure if pmh->Left and pmh->Right are showing the correct values?
Well Key, Handle, and Reserved are the exact values they should be, so
that makes me think you are reading it ok. Inch looks reasonable.
The Checksum is correct for the values listed. As for left, top,
right, bottom... not really sure.
> Plus, I have the doubt
> 'what comes next'? So after this portability header is read, should I
> expect a WMFRECORD or the actual WMFHEADER?
I suspect WMFHEADER is next.
The process is described in your link. Checksum contains a checksum
value for the previous 10 WORDs in the header, calculated by XORing
each WORD value to 0. i.e.
WORD checksum = 0;
checksum ^= 2596720087;
checksum ^= 0;
checksum ^= -1458;
unsigned short s = 0u;
s ^= 2596720087L & 0x0000FFFFL;
s ^= (2596720087L & 0xFFFF0000L) >> 16;
s ^= 0;
s ^= -1458;
s ^= -666;
s ^= 1458;
s ^= 1344;
s ^= 576;
s ^= 0;
std::cout << s << std::endl;