一、api声明:
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"
二、pb脚本:
metaheader lst_hdr
integer li_filenum
long ll_hmf,ll_loops,ll_pos,ll_len
blob 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 if
else
ll_loops = 1
end if
for ll_pos = 1 to ll_loops
fileread(li_filenum, lb_tmp)
lb_read = lb_read + lb_tmp
next
fileclose(li_filenum)
if len(lb_read) < lst_hdr.mtsize then
ll_len = len(lb_read)
else
ll_len = lst_hdr.mtsize
end if
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)
三、使用api在pb中直接读取wmf的方式源码,参考:
http://www.comesoft.net/bbs/dispbbs.asp?boardid=78&id=26663
效果图见:
http://www.comesoft.net/bbs/uploadfile/2004-12/20041229151230298.jpg
或
http://blog.csdn.net/images/blog_csdn_net/balloonman2002/17312/o_demo.gif
原贴见:http://community.csdn.net/expert/topic/3673/3673523.xml?temp=.7985193
国内最大的酷站演示中心!