Jump to content

Recommended Posts

Posted

Made major updates to the DLL and UDF and fixed (probably added new) bugs. All examples changed to new DLL / UDF.

Old scripts may fail when you use DLL v0.4.3+ as function parameters changed.

Added the function to convert APNG to AWEBP.

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

  • UEZ changed the title to WebP v0.4.4 build 2025-08-06 beta
Posted

@UEZ Hi
I was thinking at a way to keep all examples unchanged when you increase the Dll version. For example, after the last update, this is what we find in nearly each example script (there are 16 examples actually) :

If WebP_Ver2() < "0.4.4" Then Exit MsgBox($MB_ICONERROR, "ERROR", "DLL Version v0.4.4+ required!", 30)

Which means that when you'll increase the Dll version, you'll have to modify again all the examples (because the constant "0.4.4" is found in each example script)

My idea is to place the constant "0.4.4" in a single place, for example inside the function WebP_Ver2() found in WebP.au3

Actually this is the content of WebP_Ver2()

Func WebP_Ver2($sPath2DLL = "")
    Local $sDLL = Path2DLL($sPath2DLL)
    If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found
    Return DllCall($sDLL, "str", "Web_DLL_Version2")[0]
EndFunc   ;==>WebP_Ver2

It could be modified like this :

Func WebP_Ver2($sPath2DLL = "")
    Local $sDLL = Path2DLL($sPath2DLL)
    If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found
    Local $sDLLversion = DllCall($sDLL, "str", "Web_DLL_Version2")[0]
    If $sDLLversion < "0.4.4" Then ... ; UEZ will choose what to do here and what to return 
    ...
EndFunc   ;==>WebP_Ver2

So you got the idea. The final goal should be to leave all examples untouched when the Dll version increases, which means no more "0.4.4" constant in any example script. Each new version number of the Dll will be indicated only inside the function WebP_Ver2() , then you'll have less work to do while upgrading the Dll (and the user won't have to re-download the examples)

Do you think it's doable ?
Thanks

"I think you are searching a bug where there is no bug... don't listen to bad advice."

Posted

@pixelsearch let me think tomorrow about it.

 

I changed a lot of internal functions from str to wstr to support unicode filenames and all examples must be touched otherwise crash.

 

Currently I'm writing on an example in Freebasic (WebP Encoder GUI) how to use the DLL. Freebasic WebP DLL source code (my written DLL stuff, Google WebP dll will be linked as static library to my DLL) and other stuff can be found on my OneDrive, if you want to have a look under the hood.

 

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

  • UEZ changed the title to WebP v0.5.0 build 2025-08-10 beta
Posted

@UEZ hi
In "WebP Example05.au3" , if you change the last parameter in the calling function :

Global $tMem = WebP_CreateWebPAdvancedFromBitmap(...
...
True) ;hold the compressed image in memory only, no save to HDD!

to

...
False)

Does it throw this error to the Console ?

Error: 1

 

"I think you are searching a bug where there is no bug... don't listen to bad advice."

Posted

Hi @pixelsearch

you have to provide a filename otherwise error 1. Because the function expects a filename to save if last parameter is false.

The Example05.au3 is not made to save the result to the disk and load it afterwards.

 

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted (edited)

Thanks for the explanation !

For the record, I am scripting the following, to access easily any of your examples :

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Opt("MustDeclareVars", 1)

If _Doubleton("AutoIt - UEZ WebP all examples") Then Exit ; script already launched + user wants to quit

Example()

;==============================================
Func Example()

    Local $hGUI, $idMenu, $iPID, $nMsg, $sFileName

    Local $aExample[][3] = [ _
        ["01",   "WebP Example01.au3",   "View WebP image (from file, shrinked at 75%)"], _
        ["02",   "WebP Example02.au3",   "View WebP image (from memory, full size)"], _
        ["03",   "WebP Example03.au3",   "WebP image information"], _
        ["04",   "WebP Example04.au3",   "Convert to WebP lossless && lossy (simple), save"], _
        ["05",   "WebP Example05.au3",   "Convert to WebP lossy (advanced), no save"], _
        ["05.1", "WebP Example05.1.au3", "Convert to WebP lossy (advanced), save"], _
        ["06",   "WebP Example06.au3",   "Extract all frames from an animated WebP file"], _
        ["07",   "WebP Example07.au3",   "Play an animated WebP file in GUI (same thread)"], _
        ["08.1", "WebP Example08.1.au3", "Create WebP animation from GDI+ image files"], _
        ["09",   "WebP Example09.au3",   "Create WebP animation from screen capture"], _
        ["10.1", "WebP Example10.1.au3", "Converts GIF animation to WebP animation"], _
        ["11",   "WebP Example11.au3",   "Display the differences of 2 WebP images (same dimension"], _
        ["12",   "WebP Example12.au3",   "Resize a WebP image"], _
        ["13",   "WebP Example13.au3",   "Estimate the quality of a WebP image"], _
        ["14.1", "WebP Example14.1.au3", "Play an animated WebP file on Desktop (separated thread)"], _
        ["15",   "WebP Example15.au3",   "Play an animated WebP file in GUI (separated thread)"], _
        ["16.1", "WebP Example16.1.au3", "Converts a PNG animation to a WebP animation"], _
        ["17",   "WebP Example17.au3",   "Re-encode a WebP image"], _
        ["18",   "WebP Example18.au3",   "Re-encode an animated WebP file"] ]

    $hGUI = GUICreate("UEZ WebP all examples", 400, 200)

    $idMenu = GUICtrlCreateMenu("Examples") ; create all menu items immediately after this line (+++)
    For $i = 0 To Ubound($aExample) - 1
        GUICtrlCreateMenuItem($aExample[$i][0] & @TAB & $aExample[$i][2], $idMenu, -1, 1) ; last param. 1 = create a menuradioitem
    Next

    GUISetState(@SW_SHOW)

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idMenu + 1 To $idMenu + Ubound($aExample)
                $sFileName = @ScriptDir & "\" & $aExample[$nMsg - ($idMenu + 1)][1]
                If Not FileExists($sFileName) Then
                    Msgbox($MB_TOPMOST, "Script not found", $sFileName)
                Else
                    $iPID = Run(@AutoItExe & " /AutoIt3ExecuteScript " & chr(34) & $sFileName & chr(34)) ; chr(34) is "
                    If $iPID = 0 Then MsgBox($MB_TOPMOST, "Run issue : $iPID = 0 , @error = " & @error, $sFileName)
                EndIf
        EndSwitch
    WEnd

    GUIDelete($hGUI)
EndFunc   ;==>Example

;==============================================
Func _Doubleton($sTitle)

    If WinExists($sTitle) Then
        Local $iChoice = Msgbox(BitOr($MB_YESNO, $MB_DEFBUTTON2, $MB_ICONQUESTION, $MB_TOPMOST), $sTitle, _
            "This script is already running. Launch another instance ?")
        If $iChoice = $IDNO Then Return True
    EndIf
    AutoItWinSetTitle($sTitle) ; remember the AutoIt window is always hidden
EndFunc   ;==>_Doubleton

UEZWebPallexamples(181).png.eb5b56d5d816d6c4628d429e953277b2.png

Edited by pixelsearch
finished, all UEZ examples have been added to the menu

"I think you are searching a bug where there is no bug... don't listen to bad advice."

Posted
7 hours ago, UEZ said:

I added WebP Example05.1.au3.

...so I added it to the menu, all your examples have been added just now (the script in preceding post has been updated)

"I think you are searching a bug where there is no bug... don't listen to bad advice."

Posted (edited)

This is an UEZ's Example08 companion script
If you're interested in generating animations (Example08) and want to use those animation strips found online (search for "animation strips" online) to create animated images, you can use this script to easily extract individual frames from the strip and save each in a separate file so you can import them using UEZ's Example08.

In short:
Save the image containing the sequence of frames to disk.
Use this script to set and adjust (visually) the dimensions; the number of frames; the spacing between frames; and some other offsets.
Once you've defined the frames, press the "save frames" button to generate as many files as there are frames.
Now you can use UEZ's Example08 to animate the sequence.

Example:
1) Suppose you found this image at the following link:

7082845_orig.png
2) Save the image to disk.
3) Let's run this script and load that image from disk.

4) Set the parameters as follows:

efAROsn.png

5) We'll get this setting.

yYynSli.png

6) Now click "save frames" and the frames will be saved to disk. That's all.

7) Now you can use UEZ Example 8.

 

This toy was sketched out to give an idea of the concept, but it could certainly be improved and perhaps merged with Example 8 to generate a single script...
Have fun!

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <File.au3>

_GDIPlus_Startup()

; Choose Image File
Local $sPath = FileOpenDialog("Choose Image File", @ScriptDir, "Images (*.gif;*.png;*.jpg;*.bmp)| All (*.*)")
If $sPath = '' Then Exit MsgBox(16, "Error", "Sorry, no image was chosen")
; load background image
Local $hBackground = _GDIPlus_ImageLoadFromFile($sPath)

Local $iWidth = _GDIPlus_ImageGetWidth($hBackground) ;   get image width
Local $iHeight = _GDIPlus_ImageGetHeight($hBackground) ; get image Height
; Create GUI
Local $hWnd = GUICreate("Movie maker", $iWidth, $iHeight, 50, 50)
GUISetState(@SW_SHOW, $hWnd)
Local $hDC = _WinAPI_GetDC($hWnd)
Local $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC)

; === CREATE OVERLAY ===
; empty Bitmap ARGB
Local $hOverlayBmp = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)
Local $hOverlayCtx = _GDIPlus_ImageGetGraphicsContext($hOverlayBmp)

Local $hBrushTransparent = _GDIPlus_BrushCreateSolid(0x00000000)

; Fills the entire bitmap with a semi-transparent color.
Local $OverlayColor = 0xBE00FF00
_GDIPlus_GraphicsSetCompositingMode($hOverlayCtx, 1)  ; (1) - Specifies that when a color is rendered, it overwrites the background color.

; Draw background
_GDIPlus_GraphicsDrawImage($hGraphics, $hBackground, 0, 0)

; --- Create settings panel ---
If $iWidth > @DesktopWidth - 500 Then
    Local $hGUIsettings = GUICreate("Strip settings", 270, 400, @DesktopWidth - 600, 50)
Else
    Local $hGUIsettings = GUICreate("Strip settings", 270, 400, $iWidth + 70, 50)
EndIf
;
GUICtrlCreateLabel("Adgiust strip parameters here below", 20, 20, 270, 20)
;
GUICtrlCreateLabel("Top margin:", 20, 60, 100, 20)
Local $idTM = GUICtrlCreateInput(20, 150, 60, 100, 20)
GUICtrlCreateUpdown($idTM)
;
GUICtrlCreateLabel("Side margin:", 20, 90, 100, 20)
Local $idSM = GUICtrlCreateInput(6, 150, 90, 100, 20)
GUICtrlCreateUpdown($idSM)
;
GUICtrlCreateLabel("Frame height:", 20, 120, 100, 20)
Local $idFH = GUICtrlCreateInput(100, 150, 120, 100, 20)
GUICtrlCreateUpdown($idFH)
;
GUICtrlCreateLabel("Frame width:", 20, 150, 100, 20)
Local $idFW = GUICtrlCreateInput(100, 150, 150, 100, 20)
GUICtrlCreateUpdown($idFW)
;
GUICtrlCreateLabel("number of frames:", 20, 180, 120, 20)
Local $idFN = GUICtrlCreateInput(2, 150, 180, 100, 20)
GUICtrlCreateUpdown($idFN)
;
GUICtrlCreateLabel("Inter-frame gap:", 20, 210, 100, 20)
Local $idIG = GUICtrlCreateInput(10, 150, 210, 100, 20)
GUICtrlCreateUpdown($idIG)
;
GUICtrlCreateLabel("number of rows:", 20, 240, 100, 20)
Local $idRN = GUICtrlCreateInput(1, 150, 240, 100, 20)
GUICtrlCreateUpdown($idRN)
;
GUICtrlCreateLabel("Inter-row gap:", 20, 270, 100, 20)
Local $idRG = GUICtrlCreateInput(10, 150, 270, 100, 20)
GUICtrlCreateUpdown($idRG)
;
GUICtrlCreateLabel("opacity of the mask:", 20, 300, 100, 20)
Local $idMO = GUICtrlCreateInput(190, 150, 300, 100, 20)
GUICtrlCreateUpdown($idMO)
;
; === Buttons ===
Local $btnOK = GUICtrlCreateButton("Save Frames", 20, 330, 110, 30)
Local $btnRefresh = GUICtrlCreateButton("Refresh", 140, 330, 110, 30)
GUISetState(@SW_SHOW, $hGUIsettings)

ControlClick('', '', $btnRefresh)

; === MAIN LOOP ===
Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "", $aPathSplit, $iFrame = 0, $hClone
While True
    Switch GUIGetMsg()

        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $btnRefresh
            ContinueCase
            ; if any parameter changes, update the GUI accordingly
        Case $idTM, $idSM, $idFH, $idFW, $idFN, $idIG, $idMO, $idRN, $idRG
            $OverlayColor = Number("0x" & Hex(GUICtrlRead($idMO), 2) & "00FF00")
            ; add Background
            _GDIPlus_GraphicsDrawImage($hGraphics, $hBackground, 0, 0)
            ; add semitransparent layer
            _GDIPlus_GraphicsClear($hOverlayCtx, $OverlayColor)
            ; "Punches" some areas (opens holes in the semi-transparent layer).
            ; To do this, draw rectangles with alpha = 0.
            For $r = 0 To GUICtrlRead($idRN) - 1
                For $f = 0 To GUICtrlRead($idFN) - 1
                    _GDIPlus_GraphicsFillRect($hOverlayCtx, GUICtrlRead($idSM) + ($f * (GUICtrlRead($idFW) + GUICtrlRead($idIG))), GUICtrlRead($idTM) + ($r * (GUICtrlRead($idFH) + GUICtrlRead($idRG))), GUICtrlRead($idFW), GUICtrlRead($idFH), $hBrushTransparent)
                Next
            Next
            ; place the created overlay (with "holes") on the GUI
            _GDIPlus_GraphicsDrawImage($hGraphics, $hOverlayBmp, 0, 0)
        Case $btnOK
            $aPathSplit = _PathSplit($sPath, $sDrive, $sDir, $sFileName, $sExtension)
            $iFrame = 0

            For $r = 0 To GUICtrlRead($idRN) - 1
                For $f = 0 To GUICtrlRead($idFN) - 1
                    $hClone = _GDIPlus_BitmapCloneArea($hBackground, GUICtrlRead($idSM) + ($f * (GUICtrlRead($idFW) + GUICtrlRead($idIG))), GUICtrlRead($idTM) + ($r * (GUICtrlRead($idFH) + GUICtrlRead($idRG))), GUICtrlRead($idFW), GUICtrlRead($idFH), $GDIP_PXF24RGB)
                    ; Save bitmap to file
                    _GDIPlus_ImageSaveToFile($hClone, $sFileName & "_frame_" & $iFrame & ".bmp")
                    $iFrame += 1
                Next
            Next
            ; Clean up resource
            _GDIPlus_ImageDispose($hClone)
    EndSwitch
WEnd
; === CLEANUP ===
; Fine disegno overlay
_GDIPlus_BrushDispose($hBrushTransparent)
_GDIPlus_GraphicsDispose($hOverlayCtx)
_GDIPlus_BitmapDispose($hOverlayBmp)
_GDIPlus_ImageDispose($hBackground)
_GDIPlus_GraphicsDispose($hGraphics)
_WinAPI_ReleaseDC($hWnd, $hDC)
_GDIPlus_Shutdown()
GUIDelete($hGUIsettings)
GUIDelete($hWnd)
Exit

 

Edited by Gianni

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

  • UEZ changed the title to WebP v0.5.0 build 2025-08-23 beta
Posted

@UEZ hi
Before you created this WebP thread, when I needed to view a WebP image (outside of a Browser) then I used the well-known application IrfanView in its portable version, "freeware for non-commercial use" as stated on the developer page. Actual version is 4.72 (dated June 2025) and supports all OS's from Windows XP to Windows 11 . There are 59 possible plugins in a zip file and we can add the one we want : the only one I always add (when upgrading) is WebP.dll (last version from January 20, 2025)

Now that you created this thread and all your examples, I prefer to use your example01 to view a WebP image. But as the image is scaled at 75% in example01, then I quickly adapted your code to a new example01.1 without the scale process, to view the image in its full size. The script example01.1 goes like this :

;Coded by UEZ
#AutoIt3Wrapper_UseX64=y
#include "WebP.au3"

If WebP_Ver2() < "0.4.4" Then Exit MsgBox($MB_ICONERROR, "ERROR", "DLL Version v0.4.4+ required!", 30)

Global $sFile = FileOpenDialog("Select an image", "", "Images (*.webp)")
If @error Then Exit

Global Const $STM_SETIMAGE = 0x0172
_GDIPlus_Startup()
Global Const $hImage = WebP_BitmapCreateGDIp($sFile, False, (WebP_GetImageQuality($sFile) < 30 ? True : False)) ;load webp image as gdiplus, dither output image when qualitiy is below 30.

If Not $hImage Then
    _GDIPlus_Shutdown()
    Exit MsgBox($MB_ICONERROR, "Error", "Something went wrong loading the WebP image", 15)
EndIf
Global Const $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) ;convert gdiplus image to gdi image
_GDIPlus_ImageDispose($hImage) ;dispose gdiplus image

;get image dimension from gdi image
Global $tDim = DllStructCreate($tagBITMAP)
DllCall("gdi32.dll", "int", "GetObject", "int", $hBitmap, "int", DllStructGetSize($tDim), "ptr", DllStructGetPtr($tDim))
Global Const $iW = DllStructGetData($tDim, "bmWidth"), $iH = DllStructGetData($tDim, "bmHeight")

;display full size image in GUI
Global Const $hGUI = GUICreate("WebP Image Viewer", $iW, $iH)
GUISetBkColor(0xFFFFFF)
Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW - 1, $iH - 1)
_WinAPI_DeleteObject(GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap))
GUISetState()
_WinAPI_DeleteObject($hBitmap) ;dispose gdi image
_GDIPlus_Shutdown()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Then I simply added one line in "WebP Example Lister.au3" to call example01.1 directly from the lister, so this code...

["01",   "WebP Example01.au3",   "View WebP image (from file, shrinked at 75%)"], _
["02",   "WebP Example02.au3",   "View WebP image (from memory, full size)"], _

becomes...

["01",   "WebP Example01.au3",   "View WebP image (from file, shrinked at 75%)"], _
["01.1", "WebP Example01.1.au3", "View WebP image (from file, full size)"], _
["02",   "WebP Example02.au3",   "View WebP image (from memory, full size)"], _

It seems to work fine, but to make sure, could you please be kind enough and check if everything is correct in the example01.1 script ?
Thanks !

"I think you are searching a bug where there is no bug... don't listen to bad advice."

Posted

Glad you added example01.1 to the lister :thumbsup:

Also you did well checking the width & height of the full size image, in case they're greater than Desktop width & height. In this case the GUI borders would be outside the Desktop, so you scaled it in this very case to always have a GUI entirely visible inside the Desktop. I was about to script something similar but happy you made it first, bravo !

I have a question concerning the function WebP_ScaleImage, this is what we read in WebP.au3 :

; Remarks .......: Resized image will be saved lossless.

But if we launch example12 (resize a WebP image) and select "Baby Tux lossless.webp" to be resized into "Scaled.webp" (half sized) then this is what example03 (WebP image information) will show on both WebP images :

IsScaledlossy.png.c5d1335be066e7c6ebee3c1ee5862267.png

Please note how "Scaled.webp" is indicated as "lossy", which doesn't match what we read in "WebP.au3" (lossless)

For convenience, I added the name of the image in example03.au3 :

... "Image name = " & StringRegExp($sFile, '.*\\(.*)', 1)[0] & @CRLF & _

 

"I think you are searching a bug where there is no bug... don't listen to bad advice."

Posted (edited)

@pixelsearch

Should be fixed now.

Btw, can you please check if new version 0.5.1 is working for you? I added the GraphicsCaptureWrapper.dll as dynamic DLL loader at runtime.

Thank you for all your efforts and test! 👍

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted (edited)
On 8/25/2025 at 12:54 PM, UEZ said:

Btw, can you please check if new version 0.5.1 is working for you? I added the GraphicsCaptureWrapper.dll as dynamic DLL loader at runtime.

Yes, dll 0.5.1 (Aug 25, 2025) works fine for me on several examples tested (including example09 "create animation from screen capture") . So a big thanks for this :)

On 8/25/2025 at 12:54 PM, UEZ said:

Should be fixed now.

For the record, here is the comparative size of 2 "Scaled.webp" just created from "Baby Tux lossless.webp", one with dll 0.5.0 and the second one with dll 0.5.1

Scaledimagesizev2-0.5_0vs0.5.1.png.2cfae21c92936d5ff41c74b15e8b1c6a.png

Only you know if it's normal that the size of the lossless one (created with dll 0.5.1) is 2Ko smaller than the lossy one (created with dll 0.5.0)

... "Image name = " & StringRegExp($sFile, '.*\\(.*)', 1)[0] & @CRLF & _
    "Image size = " & FileGetSize($sFile) & " bytes (" & Ceiling((FileGetSize($sFile) / 1024)) & " KB)" & @CRLF & _

Edit: added size in KB (rounded up)

Edited by pixelsearch
added size in KB (rounded up)

"I think you are searching a bug where there is no bug... don't listen to bad advice."

Posted (edited)
13 minutes ago, pixelsearch said:

Only you know if it's normal that the size of the lossless one (created with dll 0.5.1) is 2Ko smaller than the lossy one created with dll 0.5.0)

This depends on the encoding setting. Even if it is lossy it can be larger then lossless. Lossy was at max. quality and lossless is at best compression. Probably image quality is the same...

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

In case some users are intrigued by 2 constants found in WebP.au3

; ====================================================================
; Explanation of a line found several times in WebP.au3
; If Int(BinaryMid($tBuffer.bin, 1, 4)) <> 1179011410 Or Int(BinaryMid($tBuffer.bin, 9, 6)) <> 88331643929943 _
;   Then Return SetError(3, 0, 0) ;header must contain RIFF and WEBPVP
; ====================================================================

Local $sHeader = "RIFF"
; Local $sHeader = "WEBPVP"

Local $iCheckSum = Asc($sHeader) ; 1st character of the string
For $i = 2 To StringLen($sHeader)
    $iCheckSum += Asc(StringMid($sHeader, $i, 1)) * 256 ^ ($i - 1)
Next
MsgBox(0, "CheckSum", $sHeader & " => " & $iCheckSum)

CheckSum.png.431c81d9a221e6ceca975ee93b38dbba.png

If it didn't make it from left to right, then I would have checked... from right to left :D

"I think you are searching a bug where there is no bug... don't listen to bad advice."

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...