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