问题
here很好地解释了如何将图片框图像转换为VB6中的字节数组.
我想反过来并从字节数组加载我的图片框图像.
我想反过来并从字节数组加载我的图片框图像.
Public Function ArrayToPicture(inArray() As Byte,Offset As Long,Size As Long) As IPicture ' function creates a stdPicture from the passed array ' Offset is first item in array: 0 for 0 bound arrays ' Size is how many bytes comprise the image Dim o_hMem As Long Dim o_lpMem As Long Dim aGUID(0 To 3) As Long Dim IIStream As IUnknown aGUID(0) = &H7BF80980 ' GUID for stdPicture aGUID(1) = &H101ABF32 aGUID(2) = &HAA00BB8B aGUID(3) = &HAB0C3000 o_hMem = GlobalAlloc(&H2&,Size) If Not o_hMem = 0& Then o_lpMem = GlobalLock(o_hMem) If Not o_lpMem = 0& Then CopyMemory ByVal o_lpMem,inArray(Offset),Size Call GlobalUnlock(o_hMem) If CreateStreamOnHGlobal(o_hMem,1&,IIStream) = 0& Then Call OleLoadPicture(ByVal ObjPtr(IIStream),0&,aGUID(0),ArrayToPicture) End If End If End If End Function
如何将偏移量和大小传递给此函数?
Size参数是组成数组中图像的总字节数,Offset是数据开始的数组的索引,这允许单个数组存储多个图像.
原文链接:https://www.f2er.com/vb/255771.html如果数组只包含一个图像,则传递它的LBound为Offset和UBound – LBound 1为Size.