Ok then try this ;Coded by UEZ 2013 -> This program requires AutoIt version 3.3.9.21 or higher!
#AutoIt3Wrapper_Autoit3Dir=c:\Program Files (x86)\AutoIt3\Beta
#include <GDIPlus.au3>
#include <Memory.au3>
_GDIPlus_Startup()
Global $sFile = StringReplace(@AutoItExe, "autoit3.exe", "Examples\GUI\msoobe.jpg")
Global $hImage = _GDIPlus_ImageLoadFromFile($sFile)
Global $hBitmap = _GDIPlus_ImageResize($hImage, 10, 7)
Global $bImage = _GDIPlus_StreamImage2BinaryString($hBitmap)
ConsoleWrite("Error: " & @error & @LF)
MsgBox(0, "Binary", $bImage)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
Func _GDIPlus_StreamImage2BinaryString($hBitmap, $sFormat = "JPG", $iQuality = 80, $bSave = False, $sFilename = "Converted.jpg") ;coded by UEZ 2013 build 2013-09-14
Local $sImgCLSID, $tGUID, $tParams
Switch $sFormat
Case "JPG"
$sImgCLSID = _GDIPlus_EncodersGetCLSID($sFormat)
$tGUID = _WinAPI_GUIDFromString($sImgCLSID)
Local $tData = DllStructCreate("int Quality")
DllStructSetData($tData, "Quality", $iQuality) ;quality 0-100
Local $pData = DllStructGetPtr($tData)
$tParams = _GDIPlus_ParamInit(1)
_GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData)
Case "PNG", "BMP", "GIF", "TIF"
$sImgCLSID = _GDIPlus_EncodersGetCLSID($sFormat)
$tGUID = _WinAPI_GUIDFromString($sImgCLSID)
Case Else
Return SetError(1, 0, 0)
EndSwitch
Local $hStream = _WinAPI_CreateStreamOnHGlobal() ;http://msdn.microsoft.com/en-us/library/ms864401.aspx
If @error Then Return SetError(2, 0, 0)
_GDIPlus_ImageSaveToStream($hBitmap, $hStream, DllStructGetPtr($tGUID), DllStructGetPtr($tParams))
If @error Then Return SetError(3, 0, 0)
_GDIPlus_BitmapDispose($hBitmap)
Local $hMemory = _WinAPI_GetHGlobalFromStream($hStream) ;http://msdn.microsoft.com/en-us/library/aa911736.aspx
If @error Then Return SetError(4, 0, 0)
Local $iMemSize = _MemGlobalSize($hMemory)
If Not $iMemSize Then Return SetError(5, 0, 0)
Local $pMem = _MemGlobalLock($hMemory)
$tData = DllStructCreate("byte[" & $iMemSize & "]", $pMem)
Local $bData = DllStructGetData($tData, 1)
_WinAPI_ReleaseStream($hStream) ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms221473(v=vs.85).aspx
_MemGlobalFree($hMemory)
If $bSave Then
Local $hFile = FileOpen($sFilename, 18)
If @error Then Return SetError(6, 0, $bData)
FileWrite($hFile, $bData)
FileClose($hFile)
EndIf
Return $bData
EndFunc ;==>_GDIPlus_StreamImage2BinaryString
Requires AutoIt version 3.3.9.21 or higher! Br, UEZ