Modify ↓
#2376 closed Bug (Works For Me)
Function fails to return a value properly
| Reported by: | NullSchritt | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | 3.3.9.14 | Severity: | None |
| Keywords: | bmp to jpeg gdi plus | Cc: |
Description
The following block of code works perfectly fine in the release version of autoit, but not in the beta, i much prefer to compile my scripts with the new betas as they seem to be the best coutnermeasure against unauthorized decompiling. I'm not sure exactly what goes wrong, but the following function returns a null string in the beta release
Func _GDIPlus_SaveImage2Binary($hBitmap, $iQuality = 60) ;Coded by Andreik, modified by UEZ
Local $sImgCLSID = _GDIPlus_EncodersGetCLSID("jpg")
Local $tGUID = _WinAPI_GUIDFromString($sImgCLSID)
Local $pEncoder = DllStructGetPtr($tGUID)
Local $tParams = _GDIPlus_ParamInit(1)
Local $tData = DllStructCreate("int Quality")
DllStructSetData($tData, "Quality", $iQuality) ;quality 0-100
Local $pData = DllStructGetPtr($tData)
_GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData)
Local $pParams = DllStructGetPtr($tParams)
Local $hStream = DllCall("ole32.dll", "uint", "CreateStreamOnHGlobal", "ptr", 0, "bool", True, "ptr*", 0)
$hStream = $hStream[3]
DllCall($ghGDIPDll, "uint", "GdipSaveImageToStream", "ptr", $hBitmap, "ptr", $hStream, "ptr", $pEncoder, "ptr", $pParams)
;~ _GDIPlus_BitmapDispose($hBitmap)
Local $hMemory = DllCall("ole32.dll", "uint", "GetHGlobalFromStream", "ptr", $hStream, "ptr*", 0)
$hMemory = $hMemory[2]
Local $iMemSize = _MemGlobalSize($hMemory)
Local $pMem = _MemGlobalLock($hMemory)
$tData = DllStructCreate("byte[" & $iMemSize & "]", $pMem)
Local $bData = DllStructGetData($tData, 1)
Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data;ptr")
DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT))
_MemGlobalFree($hMemory)
Return $bData
EndFunc ;==>__GDIPlus_SaveImage2Binary
Attachments (0)
Change History (3)
comment:1 by , 13 years ago
follow-up: 3 comment:2 by , 13 years ago
| Resolution: | → Works For Me |
|---|---|
| Status: | new → closed |
| Version: | 3.3.9.7 → 3.3.9.14 |
Note:
See TracTickets
for help on using tickets.

Did you try with v3.3.9.13? As there was an issue with _WinAPI_GUIDFromString that I fixed.