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

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...