Modify

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#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 Changed 11 years ago by guinness

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

comment:2 follow-up: Changed 11 years ago by guinness

  • Resolution set to Works For Me
  • Status changed from new to closed
  • Version changed from 3.3.9.7 to 3.3.9.14

comment:3 in reply to: ↑ 2 Changed 11 years ago by anonymous

Replying to guinness:
This fixed it, thanks.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.