回复 1# 木头人
给你一个函数,是把保存为字符串形式的图片直接放在控件上:
;$s_Binary为二进制形式的字符串,$ctrl控件ID
Func _BinaryToCtrl($s_Binary, $ctrl) ;code by Montfrooij
Local $b_PicData = Binary($s_Binary)
Local $i_PicLength = BinaryLen($b_PicData)
Local $t_PicStruct = DllStructCreate("byte[" & $i_PicLength & "]")
DllStructSetData($t_PicStruct, 1, $b_PicData)
Local $p_PicMemory = DllStructGetPtr($t_PicStruct)
Local $h_Memory = _MemGlobalAlloc($i_PicLength, 2)
Local $p_Memory = _MemGlobalLock($h_Memory)
_MemMoveMemory($p_PicMemory, $p_Memory, $i_PicLength)
_MemGlobalUnlock($h_Memory)
Local $p_Stream = DllCall("Ole32.dll", "int", "CreateStreamOnHGlobal", "int", $h_Memory, "long", 1, "Int*", 0)
$p_Stream = $p_Stream[3]
Local $p_Bitmap = DllCall($ghGDIPDll, "int", "GdipCreateBitmapFromStream", "ptr", $p_Stream, "int*", 0)
$p_Bitmap = $p_Bitmap[2]
$t_PicStruct = 0
$hBitmap2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($p_Bitmap)
_GDIPlus_ImageDispose($p_Bitmap)
Local $h_Wnd = GUICtrlGetHandle($ctrl)
Local $a_Ret = DllCall("User32.dll", "hwnd", "SendMessage", "hwnd", $h_Wnd, "int", 0x0172, "int", 0, "int", $hBitmap2)
If $a_Ret[0] <> 0 Then _WinAPI_DeleteObject($a_Ret[0])
EndFunc
|