Danke ![]()
Für alle die faul sind und auf diesen Thread deswegen gestoßen sind:
Spoiler anzeigen
#Include <Memory.au3>
Func Load_BMP_From_Mem($pic) ;thanks to ProgAndy for mem allocation lines
Local $memBitmap, $len, $tMem, $hImage, $hData, $pData, $hStream, $hBitmapFromStream
$memBitmap = Binary($pic) ;load image saved in variable (memory) and convert it to binary
$len = BinaryLen($memBitmap) ;get length of image
$hData = _MemGlobalAlloc($len, 0x0002) ;allocates movable memory ($GMEM_MOVEABLE = 0x0002)
$pData = _MemGlobalLock($hData) ;translate the handle into a pointer
$tMem = DllStructCreate("byte[" & $len & "]", $pData) ;create struct
DllStructSetData($tMem, 1, $memBitmap) ;fill struct with image data
_MemGlobalUnlock($hData) ;decrements the lock count associated with a memory object that was allocated with GMEM_MOVEABLE
$hStream = _WinAPI_CreateStreamOnHGlobal($pData) ;Creates a stream object that uses an HGLOBAL memory handle to store the stream contents
$hBitmapFromStream = _GDIPlus_BitmapCreateFromStream($hStream) ;Creates a Bitmap object based on an IStream COM interface
$tMem = ""
Return $hBitmapFromStream
EndFunc
Func _WinAPI_CreateStreamOnHGlobal($hGlobal = 0, $fDeleteOnRelease = True)
Local $aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "hwnd", $hGlobal, "int", $fDeleteOnRelease, "ptr*", 0)
If @error Then Return SetError(@error, @extended, 0)
Return $aResult[3]
EndFunc ;==>_WinAPI_CreateStreamOnHGlobal
Func _GDIPlus_BitmapCreateFromStream($pStream)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $pStream, "int*", 0)
If @error Then Return SetError(@error, @extended, 0)
Return $aResult[2]
EndFunc ;==>_GDIPlus_BitmapCreateFromStream