debugged ENHANCEDMETAHEADER for Delphi

Please discuss general Delphi programming topics here.

debugged ENHANCEDMETAHEADER for Delphi

Postby norbert » May 31st, 2006, 8:28 pm

The documentation of ENHANCEDMETAHEADER in MSN seems to be faulty. I always constated that FrameLeft and FrameRight both are 0 when Frame Top and FrameRight are 0.
So I changed the record definition and everything runs well.

Code: Select all
type ENHANCEDMETAHEADER = record
     RecordType : dword;          // Record type
     RecordSize : dword;          // Size of the record in bytes
     BoundsLeft : integer;        // Left inclusive bounds
     BoundsRight : integer;       // Right inclusive bounds
     BoundsTop : integer;         // Top inclusive bounds
     BoundsBottom : integer;      // Bottom inclusive bounds
     FrameLeft : integer;         // Left side of inclusive picture frame
     FrameTop : integer;          // Top side of inclusive picture frame
     FrameRight : integer;        // Right side of inclusive picture frame
     FrameBottom : integer;       // Bottom side of inclusive picture frame
     Signature : dword;           // Signature ID (always 0x464D4520)
     Version : dword;             // Version of the metafile
     Size : dword;                // Size of the metafile in bytes
     NumOfRecords : dword;        // Number of records in the metafile
     NumOfHandles : word;         // Number of handles in the handle table
     Reserved : word;             // Not used (always 0)
     SizeOfDescrip : dword;       // Size of description string in WORDs
     OffsOfDescrip : dword;       // Offset of description string in metafile
     NumPalEntries : dword;       // Number of color palette entries
     WidthDevPixels : integer;    // Width of reference device in pixels
     HeightDevPixels : integer;   // Height of reference device in pixels
     WidthDevMM : integer;        // Width of reference device in millimeters
     HeightDevMM : integer;       // Height of reference device in millimeters
end;


Simple code to test it: (comments are results of one of my EMF test files)

//Die EMF Header einlesen
fileStream := TFileStream.Create(sMetaPathFileName, fmOpenRead);
sz := sizeof(ENH);
fileStream.Read(ENH, sz);
fileStream.Free;

showmessage(inttostr(enh.BoundsBottom)); // 926
showmessage(inttostr(enh.BoundsLeft)); // 105
showmessage(inttostr(enh.BoundsRight)); // 241
showmessage(inttostr(enh.BoundsTop)); // 695
showmessage(inttostr(enh.FrameBottom)); // 29700
showmessage(inttostr(enh.FrameLeft)); // 0
showmessage(inttostr(enh.FrameRight)); // 20300
showmessage(inttostr(enh.FrameTop)); // 0
showmessage(inttostr(enh.HeightDevMM)); // 297
showmessage(inttostr(enh.HeightDevPixels));// 1169
showmessage(inttostr(enh.NumOfHandles)); // 8
showmessage(inttostr(enh.NumOfRecords)); // 2522
showmessage(inttostr(enh.NumPalEntries)); // 0
showmessage(inttostr(enh.OffsOfDescrip)); // 108
showmessage(inttostr(enh.RecordSize)); // 132
showmessage(inttostr(enh.RecordType)); // 1
showmessage(inttostr(enh.Reserved)); // 0
showmessage(inttostr(enh.Signature)); // 1179469088 = 464D4520
showmessage(inttostr(enh.Size)); // 47972
showmessage(inttostr(enh.SizeOfDescrip)); // 12
showmessage(inttostr(enh.Version)); // 65536 = 0x10000
showmessage(inttostr(enh.WidthDevMM)); // 203
showmessage(inttostr(enh.WidthDevPixels)); // 800


Hope it helps,
Norbert
norbert
Active Member
Active Member
 
Posts: 17
Joined: May 13th, 2006, 8:49 am
Location: Germany

Postby Kambiz » May 31st, 2006, 9:19 pm

Thank you!
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

ENHANCEDMETAHEADER for Delphi

Postby norbert » June 1st, 2006, 9:40 pm

Kambiz,

not even the size of the header is correct by MS!

Instead of 80 bytes it has 88 Bytes in reality.

The var section of my sample is:

Code: Select all
var
   sz : integer;
   ENH : ENHANCEDMETAFILEHEADER;

(for those who are not familiar with everything in abbreviated code)

Norbert
norbert
Active Member
Active Member
 
Posts: 17
Joined: May 13th, 2006, 8:49 am
Location: Germany


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 2 guests