First, API declaration:
SUBROUTINE CopyMemory (ref METAHEADER Destination, ref blob Source, long Length) LIBRARY "kernel32" Alias for "RtlMoveMemory" SUBROUTINE CopyMemory2 (ref blob Destination, ref blob Source, long Length) LIBRARY "kernel32" Alias for "RtlMoveMemory" Function ulong SetMetaFileBitsEx ( Ulong nsize, ref blob lpdata) library "gdi32.dll"
Second, PB scripts:
MetaHeader LST_HDRINTEGER LI_FILENUMLONG LL_HMF, LL_LOOPS, LL_POS, LL_LENBLOB LB_STRUCTURE, LB_DATA, LB_TMP, LB_READ
Li_Filenum = FileOpen ("C: /1.WMF", streammode!)
Fileseek (li_filenum, 22, frombeginning!)
FileRead (li_filenum, lb_structure)
CopyMemory (LST_HDR, LB_STRUCTURE, 18)
LST_HDR.MTSIZE = LST_HDR.MTSIZE * 2
Fileseek (li_filenum, 22, frombeginning!)
IF lst_Hdr.mtSize> 32765 THEN IF Mod (lst_Hdr.mtSize, 32765) = 0 THEN ll_loops = lst_Hdr.mtSize / 32765 ELSE ll_loops = (lst_Hdr.mtSize / 32765) 1 END IFELSE ll_loops = 1END IF
For ll_pos = 1 to ll_loops fileread (li_filenum, lb_tmp) lb_read = lb_read lb_tmpnext
FILECLOSE (li_filenum)
IF LEN (LB_READ) LB_DATA = blob (space (ll_len)) CopyMemory2 (LB_Data, LB_READ, LL_LEN) Ll_hmf = setmetafilebitsex (LST_HDR.MTSIZE, LB_DATA) OLE_1.Object.objcreatePicture (1, 1, 3, 6, ll_hmf, 7, 0, 0) Third, using the API directly read the WMF mode source code, reference: http://www.netsoft.net/bbs/dispbbs.asp?boardid=78&id=26663 See the renderings: