#PRE_UseX64=n
#include <GDIPlus.au3>
Local $hFile = FileOpen('test_webp.webp',16)
Local $bData=FileRead($hFile)
FileClose($hFile)
Local $Buffer = DllStructCreate('byte[' & BinaryLen($bData) & ']')
DllStructSetData($Buffer, 1, $bData)
Local $Width, $Height
Local $pBGRAData = WebPDecodeBGRA(DllStructGetPtr($Buffer), BinaryLen($bData), $Width, $Height)
Local $sFile = @ScriptDir & "\Test.jpg"
_GDIPlus_Startup()
Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($Width, $Height, $GDIP_PXF32ARGB, BitShift($Width, -2), $pBGRAData)
_GDIPlus_ImageSaveToFile($hBitmap, $sFile)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_Shutdown()
If $pBGRAData Then WebPFree($pBGRAData)
Func WebPDecodeBGRA($pData, $data_size, ByRef $Width, ByRef $Height)
Local $Ret = DllCall('libwebp.dll', 'ptr:cdecl', 'WebPDecodeBGRA', 'ptr', $pData, 'DWORD', $data_size, 'DWORD*', 0, 'DWORD*', 0)
$Width = $Ret[3]
$Height = $Ret[4]
Return $Ret[0]
EndFunc ;==>WebPDecodeBGRA
Func WebPFree($pData)
Local $Ret = DllCall('libwebp.dll', 'ptr:cdecl', 'WebPFree', 'ptr', $pData)
Return $Ret[0]
EndFunc ;==>WebPFree
|