您的位置:程序门 -> vb -> 基础类



新手刚来:我有一个jpg图在一个byte数组内请问如何用picturebox显示


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


新手刚来:我有一个jpg图在一个byte数组内请问如何用picturebox显示[已结贴,结贴人:skamy]
发表于:2007-03-17 17:51:20 楼主
我有一个jpg图在一个byte数组内请问如何用picturebox显示,最好能有关键代码
发表于:2007-03-17 17:56:421楼 得分:0
setdibits   可能行
发表于:2007-03-17 19:26:322楼 得分:0
how   to   show   picture   in   picture   box   from   array


http://www.experts-exchange.com/programming/languages/visual_basic/q_20166009.html?qid=20166009
发表于:2007-03-18 21:54:373楼 得分:0
up
发表于:2007-03-19 00:05:364楼 得分:0
to   hongqi162(失踪的月亮)
好象注册还要付费?能不能直接把内容贴出来啊?
发表于:2007-03-19 08:33:345楼 得分:20
public   declare   function   createstreamonhglobal   lib   "ole32 "   (byval   hglobal   as   long,   byval   fdeleteonrelease   as   long,   ppstm   as   any)   as   long
public   declare   function   oleloadpicture   lib   "olepro32 "   (pstream   as   any,   byval   lsize   as   long,   byval   frunmode   as   long,   riid   as   any,   ppvobj   as   any)   as   long
public   declare   function   clsidfromstring   lib   "ole32 "   (byval   lpsz   as   any,   pclsid   as   any)   as   long
public   declare   function   globalalloc   lib   "kernel32 "   (byval   uflags   as   long,   byval   dwbytes   as   long)   as   long
public   declare   function   globallock   lib   "kernel32 "   (byval   hmem   as   long)   as   long
public   declare   function   globalunlock   lib   "kernel32 "   (byval   hmem   as   long)   as   long
public   declare   function   globalfree   lib   "kernel32 "   (byval   hmem   as   long)   as   long
public   declare   sub   copymemory   lib   "kernel32 "   alias   "rtlmovememory "   (destination   as   any,   source   as   any,   byval   length   as   long)

'**************************************************************
'   参数说明:
'
'   bimagedata():   保存图像信息的字节数组。
'
'   返回值:
'
'   返回转换后的   ipictredisp   对象。
'**************************************************************
public   function   getpicturefrombytestream(bimagedata()   as   byte)   as   ipicture
dim   lngbytecount   as   long
dim   hmem   as   long
dim   lpmem   as   long
dim   iid_ipicture(15)
dim   istream   as   stdole.iunknown

on   error   goto   err_init

lngbytecount   =   ubound(bimagedata)   +   1   '   计算数组大小
hmem   =   globalalloc(&h2   or   gmem_zeroinit,   lngbytecount)   '   按数组大小分配一块内存空间
if   hmem   <>   0   then
' '   若分配内存成功
lpmem   =   globallock(hmem)   '   锁定内存,   返回第一块的指针
if   lpmem   <>   0   then
copymemory   byval   lpmem,   bimagedata(0),   lngbytecount
call   globalunlock(hmem)
if   createstreamonhglobal(hmem,   1,   istream)   =   0   then
if   clsidfromstring(strptr( "{7bf80980-bf32-101a-8bbb-00aa00300cab} "),   iid_ipicture(0))   =   0   then
call   oleloadpicture(byval   objptr(istream),   lngbytecount,   0,   iid_ipicture(0),   getpicturefrombytestream)
end   if
end   if
end   if
end   if

globalfree   hmem

exit   function

err_init:
msgbox   err.number   &   "   -   "   &   err.description
end   function


把图像数据存入字节数组,按如下调用即可:

set   picture1.picture=getpicturefrombytestream(bytdata())


快速检索

最新资讯
热门点击