-
Posts
7,390 -
Joined
-
Last visited
-
Days Won
87
UEZ last won the day on August 16
UEZ had the most liked content!
About UEZ

- Birthday 12/03/2007
Profile Information
-
Member Title
Never say never
-
Location
Germany
-
Interests
Computer, watching movies, football (soccer), being lazy :-)
UEZ's Achievements
-
pixelsearch reacted to a post in a topic: WebP v0.5.0 build 2025-08-23 beta
-
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...
-
UEZ reacted to a post in a topic: WebP v0.5.0 build 2025-08-23 beta
-
@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! 👍
-
UEZ reacted to a post in a topic: WebP v0.5.0 build 2025-08-23 beta
-
Danyfirex reacted to a post in a topic: DLL Call Problems
-
pixelsearch reacted to a post in a topic: DLL Call Problems
-
Never say never 😉 It was too late and I forgot to set the correct stride value for 24bit capturing. I uploaded the x86 version which should work now. We’ll figure it out if it’s still not working.
-
Sorry, I was not drunken but I was in a different function - doh. Yes, WebP_CreateWebPCreateAnimFromScreenCapture was heavily modified to get more speed. It is a good question, what causes the issues now. I added a new parameter "$bXPMode" to Web.au3: Func WebP_CreateWebPCreateAnimFromScreenCapture($x, $y, $w, $h, $sec, $sOutfile, $fps = 30, $CapCursor = 1, $quality = 75.0, $lossless = 0, $method = 0, $filter_strength = 60, $sns_strength = 50, _ $pass = 1, $filter_sharpness = 0, $near_lossless = 100, $alpha_compression = 0, $alpha_filtering = 0, $alpha_quality = 100, $target_size = 0, $loop_count = 0, _ $WebPImageHint = $WEBP_HINT_DEFAULT, $pCallback = 0, $bXPMode = False, $sPath2DLL = "") Please set it to true and try again. Btw, WebP officially only supports Vista+ operating systems! You are lucky that it works with WinXP.
-
UEZ reacted to a post in a topic: DLL Call Problems
-
WebP_CreateWebPCreateAnim(), WebP_GetAnimFileInfo(), WebP_ConvertAPNG2WebP(), WebP_ScaleImage() and WebP_GetImageQuality() are using _WinAPI_FileExistsW, too. Can you please check if these examples are working? Can you try to mark fullscreen and test?
-
I assume it has something to do with GraphicsCaptureWrapper.dll which I added again and this seems not to be compatible with WinXP. The uploaded version was 0.5.1. I removed the GraphicsCaptureWrapper code from the DLL. Please try it again. Maybe I will leave GraphicsCaptureWrapper out of the DLL because on my Notebook it doesn't give me a real benefit regarding capturing speed. GraphicsCaptureWrapper should use the GPU and should be able to capture fullscreen at 60 fps.
-
I'm sorry to hear that. 😔 You’re just a year younger than my mother – really impressive that you’re working with programming! v0.5.0 animation is just the header only. As the file is created, I assume you didn't get any error message, right? I updated the x86 version only. Can you please test it? I changed the variable timestamp_ms back to long again. The only difference which is left is the "_WinAPI_FileExistsW" function which checks Unicode files names. FB can only check ANSI file names.
-
pixelsearch reacted to a post in a topic: DLL Call Problems
-
Thanks for your feedback. 1) I uploaded the missing animation. 2) I tested it with x86 and the capturing worked. Did you get an error message? The difference between the two is only slight. In 0.5.0 file exists is using winapi unicode version instead of FB built-in function. _WinAPI_FileExistsW() is also used by several other functions. Another difference is the declaration of a variable: old: long, new: integer. Btw, why are you still on WinXP?
-
UEZ reacted to a post in a topic: DLL Call Problems
-
UEZ reacted to a post in a topic: WebP v0.5.0 build 2025-08-23 beta
-
argumentum reacted to a post in a topic: DLL Call Problems
-
Look here for ScreenCapture2WebPAnim.7z Start ScreenCapture2WebPAnim.exe (x64 compiled as console app) and it will record main screen for 20 seconds and save the result to Capture_1920x1080.webp. Requires Win10 build 18362+! It calls the function WebP_CreateWebPCreateAnimFromGraphicsCapture in the WebP DLL which calls GraphicsCaptureWrapper DLL. Function WebP_CreateWebPCreateAnimFromGraphicsCapture(_ ByVal x As Long, ByVal y As Long, ByVal w As Long, ByVal h As Long, ByVal sec As Long, ByVal fps As UShort, ByVal sFileOut As WString Ptr, _ ByVal CapCursor As UByte = 0, ByVal loopcount As Long = 0, ByVal pWebPConfig As WebPConfig Ptr, ByVal pCallback As Any Ptr = 0) As Long Export If OS.dwBuildNumber < 18362 Then Return -1 If w < 1 OrElse h < 1 Then Return -2 If sec < 1 Then Return -3 If fps < 1 Then Return -4 If sFileOut = 0 Then Return -5 Dim As Long actualW, actualH, result result = InitRegionCapture(x, y, w, h, actualW, actualH) If result <> 1 Then Return -6 pWebPConfig->thread_level = 1 If WebPValidateConfig(pWebPConfig) = 0 Then Return -8 Dim As WebPAnimEncoderOptions enc_options WebPAnimEncoderOptionsInit(@enc_options) 'enc_options.verbose = 1 Dim As WebPAnimEncoder Ptr pEnc = WebPAnimEncoderNew(actualW, actualH, @enc_options) Dim As WebPPicture pic If WebPPictureAlloc(@pic) <> VP8_STATUS_OK Then WebPPictureFree(@pic) Return -9 End If If WebPPictureInitInternal(@pic, WEBP_ENCODER_ABI_VERSION) = 0 Then Return -10 pic.width = actualW pic.height = actualH pic.use_argb = 1 If pCallback Then AutoItProgressCB = Cast(AutoItProgressCallback, pCallback) ' Buffer vorbereiten Dim As Long stride = actualW * 4 Dim As ULong bufferSize = stride * actualH Dim frameBuffer As UByte Ptr = Allocate(bufferSize) If frameBuffer = 0 Then WebPPictureFree(@pic) Return -11 End If timeBeginPeriod(1) Dim As Long frame_delay_ms = 1000 \ fps, total_frames = sec * fps, maxDuration = sec * 1000, delay Dim As Integer timestamp_ms = 0 Dim As Long frameIndex, frameResult timeBeginPeriod(1) Dim As LONGLONG tStart = SafeGetTickCount64(), tCurrent Dim As Double fTimer = Timer, fEnd, fTimerSleep While True fTimerSleep = Timer timestamp_ms = SafeGetTickCount64() - tStart If AutoItProgressCB <> 0 Then If AutoItProgressCB(timestamp_ms / maxDuration * 100, 0) = 0 Then Exit While End If frameResult = GetCapturedFrame(frameBuffer, bufferSize) If frameResult = 1 Then WebPPictureImportBGRA(@pic, frameBuffer, stride) WebPAnimEncoderAdd(pEnc, @pic, timestamp_ms, pWebPConfig) frameIndex += 1 End If If SafeGetTickCount64() - tStart > maxDuration Then Exit While delay = frame_delay_ms - (Timer - fTimerSleep) Sleep(IIf(delay < 0, 0, delay) , 1) Wend fEnd = Timer - fTimer timeEndPeriod(1) WebPPictureFree(@pic) WebPAnimEncoderAdd(pEnc, NULL, frameIndex * frame_delay_ms, NULL) Dim As WebPData webp_data WebPDataInit(@webp_data) If WebPAnimEncoderAssemble(pEnc, @webp_data) = 0 Then WebPDataClear(@webp_data) WebPAnimEncoderDelete(pEnc) Deallocate(frameBuffer) CleanupCapture() Return -12 End If ' Loop Count setzen loopcount = IIf(loopcount < 0, 0, loopcount) Dim As WebPMux Ptr pMux = WebPMuxCreate(@webp_data, 1) Dim As WebPMuxAnimParams new_params WebPMuxGetAnimationParams(pMux, @new_params) new_params.loop_count = loopcount WebPMuxSetAnimationParams(pMux, @new_params) WebPMuxAssemble(pMux, @webp_data) WebPMuxDelete(pMux) WebPAnimEncoderDelete(pEnc) Deallocate(frameBuffer) CleanupCapture() ' Datei speichern If webp_data.size > 0 Then If SaveWebPImageBin(sFileOut, webp_data.size, Cast(UByte Ptr, webp_data.bytes)) < 1 Then WebPDataClear(@webp_data) Return -13 End If Else WebPDataClear(@webp_data) Return -14 End If WebPDataClear(@webp_data) Return 1 End Function In that function InitRegionCapture() will be called to init screen region.
-
pixelsearch reacted to a post in a topic: DLL Call Problems
-
Sure __declspec(dllexport) int InitRegionCapture(int x, int y, int regionWidth, int regionHeight, int* actualWidth, int* actualHeight) { if (g_ctx && g_ctx->isCapturing) { if (actualWidth) *actualWidth = g_ctx->width; if (actualHeight) *actualHeight = g_ctx->height; return 1; } if (!InitializeCaptureCommon()) return 0; g_ctx->mode = CaptureMode::Region; try { HMONITOR primaryMonitor = MonitorFromWindow(GetDesktopWindow(), MONITOR_DEFAULTTOPRIMARY); MONITORINFO mi{ sizeof(MONITORINFO) }; if (!GetMonitorInfoA(primaryMonitor, &mi)) return 0; int monitorWidth = mi.rcMonitor.right - mi.rcMonitor.left; int monitorHeight = mi.rcMonitor.bottom - mi.rcMonitor.top; x = std::max(0, x); y = std::max(0, y); if (x >= monitorWidth || y >= monitorHeight) return 0; if (x + regionWidth > monitorWidth) regionWidth = monitorWidth - x; if (y + regionHeight > monitorHeight) regionHeight = monitorHeight - y; if (regionWidth <= 0 || regionHeight <= 0) return 0; g_ctx->regionX = x; g_ctx->regionY = y; g_ctx->regionWidth = regionWidth; g_ctx->regionHeight = regionHeight; g_ctx->fullMonitorWidth = monitorWidth; g_ctx->fullMonitorHeight = monitorHeight; g_ctx->width = regionWidth; g_ctx->height = regionHeight; auto itemInterop = winrt::get_activation_factory<GraphicsCaptureItem, IGraphicsCaptureItemInterop>(); HRESULT hr = itemInterop->CreateForMonitor( primaryMonitor, winrt::guid_of<GraphicsCaptureItem>(), winrt::put_abi(g_ctx->item) ); if (FAILED(hr)) return 0; } catch (...) { return 0; } if (actualWidth) *actualWidth = g_ctx->regionWidth; if (actualHeight) *actualHeight = g_ctx->regionHeight; return FinalizeCaptureSetup(nullptr, nullptr); } WindowsXP? Really? 😲 I found 0.4.3 #cs Copyright (c) 2025 UEZ The following terms apply to the use of this code (AutoIt scripts and both DLLs), unless otherwise agreed upon in writing with the author: 1. **No commercial use** Any commercial usage - including but not limited to selling, licensing, integrating into commercial software, or using in revenue-generating products - is prohibited. 2. **Modification allowed, for non-commercial use only** You may modify or adapt the code as long as it remains non-commercial. Even in modified versions, the original author must be clearly credited as UEZ. 3. **Attribution required** In any non-commercial distribution or use, clear credit must be given to the original author: UEZ. For exceptions or commercial licensing, please contact: uez at hotmail de #ce ;Version 0.4.3 build 2025-08-03 beta #include-once #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <Memory.au3> #include <MsgBoxConstants.au3> #include <WinAPIGdi.au3> #include <WindowsConstants.au3> #include <WinAPIConstants.au3> #include <WinAPISysWin.au3> ;~ #include <WinAPIDiag.au3> ;WEBP_HINT_ENUMARTION Enum $WEBP_HINT_DEFAULT = 0, _ ; default preset. $WEBP_HINT_PICTURE, _ ; digital picture, like portrait, inner shot $WEBP_HINT_PHOTO, _ ; outdoor photograph, with natural lighting $WEBP_HINT_GRAPH, _ ; Discrete tone image (graph, map-tile etc). $WEBP_HINT_LAST Global Const $tagWebPConfig = _ "long lossless;" & _ "float quality;" & _ "long method;" & _ "long image_hint;" & _ "long target_size;" & _ "float target_PSNR;" & _ "long segments;" & _ "long sns_strength;" & _ "long filter_strength;" & _ "long filter_sharpness;" & _ "long filter_type;" & _ "long autofilter;" & _ "long alpha_compression;" & _ "long alpha_filtering;" & _ "long alpha_quality;" & _ "long pass;" & _ "long show_compressed;" & _ "long preprocessing;" & _ "long partitions;" & _ "long partition_limit;" & _ "long emulate_jpeg_size;" & _ "long thread_level;" & _ "long low_memory;" & _ "long near_lossless;" & _ "long exact;" & _ "long use_delta_palette;" & _ "long use_sharp_yuv;" & _ "long qmin;" & _ "long qmax" Global $g_hDLL ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_Ver ; Description ...: Displays the DLL version information in a messagebox window ; Syntax ........: WebP_Ver([$sPath2DLL = ""]) ; Parameters ....: $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir ; Return values .: None ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_Ver($sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found DllCall($sDLL, "none", "WebP_DLL_Version") Return True EndFunc ;==>WebP_Ver ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_Ver2 ; Description ...: Returns the DLL version information ; Syntax ........: WebP_Ver([$sPath2DLL = ""]) ; Parameters ....: $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir ; Return values .: DLL version ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== 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 ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_BitmapGetInfo ; Description ...: Gets some rudimentary information about the WebP image ; Syntax ........: WebP_BitmapGetInfo($sFilename[, $sPath2DLL = ""]) ; Parameters ....: $sFilename - file to load ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir ; Return values .: Struct ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://developers.google.com/speed/webp ; Example .......: No ; =============================================================================================================================== Func WebP_BitmapGetInfo($sFilename, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found If Not FileExists($sFilename) Then Return SetError(2, 0, 0) ;file not found Local $iFileSize = FileGetSize($sFilename), $nBytes Local $tBuffer = DllStructCreate("struct;byte bin[" & $iFileSize & "];endstruct") Local Const $hFile = _WinAPI_CreateFile($sFilename, 2, 2) _WinAPI_ReadFile($hFile, $tBuffer, $iFileSize, $nBytes) _WinAPI_CloseHandle($hFile) 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 $tWebPBitstreamFeatures = DllStructCreate("struct;long width; long height; long has_alpha; long has_animation; long format; ulong pad[5];endstruct") Local $iReturn = DllCall($sDLL, "long", "WebP_BitmapGetInfo", "struct*", $tBuffer, "uint", $iFileSize, "struct*", $tWebPBitstreamFeatures) If $iReturn = 0 Then Return SetError(4, 0, 0) Return $tWebPBitstreamFeatures EndFunc ;==>WebP_BitmapGetInfo ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_BitmapCreateGDIp ; Description ...: Converts (decodes) a WebP image from disk to a GDI / GDI+ bitmap handle ; Syntax ........: WebP_BitmapCreateGDIp($sFilename[, $bGDIImage = False[, $bDither = False[, $iDitherStrength = 32[, ; $bCountColors = False[, $sPath2DLL = ""]]]]]) ; Parameters ....: $sFilename - file to load ; $bGDIImage - [optional] a boolean value. Default is False (GDIPlus bitmap handle). If True then output is GDI bitmap handle. ; $bDither - [optional] a boolean value. Default is False. If true pseudo dithering (noise) will applied to image. ; $iDitherStrength - [optional] an integer value. Default is 32. Valid values are from 0 to 64. ; $bCountColors - [optional] a boolean value. Default is False. If True then the colors will be counted and saved in extended. Use @extended to get color count. ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir ; Return values .: GDI / GDIPlus bitmap handle and color count if $bCountColors = True in extended. ; Author ........: UEZ ; Modified ......: ; Remarks .......: For animated WebP images see below! Dithering makes only sense for images which are heavily compressed. ; Related .......: ; Link ..........: https://developers.google.com/speed/webp ; Example .......: No ; =============================================================================================================================== Func WebP_BitmapCreateGDIp($sFilename, $bGDIImage = False, $bDither = False, $iDitherStrength = 32, $bCountColors = False, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found If Not FileExists($sFilename) Then Return SetError(2, 0, 0) ;file not found $iDitherStrength = $iDitherStrength > 64 ? 64 : $iDitherStrength < 0 ? 0 : $iDitherStrength Local $iFileSize = FileGetSize($sFilename), $nBytes If $iFileSize < 1 Then Return SetError(3, 0, 0) Local $tBuffer = DllStructCreate("byte bin[" & $iFileSize & "]") Local Const $hFile = _WinAPI_CreateFile($sFilename, 2, 2) _WinAPI_ReadFile($hFile, $tBuffer, $iFileSize, $nBytes) _WinAPI_CloseHandle($hFile) If Int(BinaryMid($tBuffer.bin, 1, 4)) <> 1179011410 Or Int(BinaryMid($tBuffer.bin, 9, 6)) <> 88331643929943 Then Return SetError(4, 0, 0) ;header must contain RIFF and WEBPVP Local $tColors = DllStructCreate("struct;ulong cc;endstruct") Local Const $hBitmap = DllCall($sDLL, "ptr", "WebP_BitmapCreateGDIp", "struct*", $tBuffer, "uint", $iFileSize, "boolean", $bDither, "ubyte", $iDitherStrength, "boolean", $bGDIImage, "boolean", $bCountColors, "struct*", $tColors)[0] If $hBitmap = 0 Then Return SetError(5, 0, 0) Return SetExtended($tColors.cc, $hBitmap) EndFunc ;==>WebP_BitmapCreateGDIp ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_BitmapCreateGDIpFromMem ; Description ...: Converts (decodes) a WebP image from memory to a GDI / GDI+ bitmap handle ; Syntax ........: WebP_BitmapCreateGDIpFromMem($tBuffer[, $iBufferSize = 0[, $bGDIImage = False[, $bDither = False[, ; $iDitherStrength = 32[, $bCountColors = False[, $sPath2DLL = ""]]]]]]) ; Parameters ....: $tBuffer - a dll struct with WebP binary data as content or pointer to the memory data. ; $iBufferSize - the size of the binary data (file size). ; $bGDIImage - [optional] a boolean value. Default is False (GDIPlus bitmap handle). If True then output is GDI bitmap handle. ; $bDither - [optional] a boolean value. Default is False. If true pseudo dithering (noise) will applied to image. ; $iDitherStrength - [optional] an integer value. Default is 32. Valid values are from 0 to 64. ; $bCountColors - [optional] a boolean value. Default is False. If True then the colors will be counted and saved in extended. Use @extended to get color count. ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir ; Return values .: GDI / GDIPlus bitmap handle and color count if $bCountColors = True in extended. ; Author ........: UEZ ; Modified ......: ; Remarks .......: Currently only WebP images are supported - no animated WebP images yet! ; Related .......: ; Link ..........: https://developers.google.com/speed/webp ; Example .......: No ; =============================================================================================================================== Func WebP_BitmapCreateGDIpFromMem($tBuffer, $iBufferSize = 0, $bGDIImage = False, $bDither = False, $iDitherStrength = 32, $bCountColors = False, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found If $iBufferSize = 0 Then Return SetError(2, 0, 0) Local $binMem If IsPtr($tBuffer) Then Local $tMem = DllStructCreate("byte bin[" & $iBufferSize & "]", $tBuffer) $binMem = $tMem.bin Else $binMem = DllStructGetData($tBuffer, 1) EndIf If Int(BinaryMid($binMem, 1, 4)) <> 1179011410 Or Int(BinaryMid($binMem, 9, 6)) <> 88331643929943 Then Return SetError(3, 0, 0) ;header must contain RIFF and WEBPVP Local $tColors = DllStructCreate("ulong cc") Local Const $hBitmap = DllCall($sDLL, "ptr", "WebP_BitmapCreateGDIp", "struct*", $tBuffer, "uint", $iBufferSize, "boolean", $bDither, "ubyte", $iDitherStrength, "boolean", $bGDIImage, "boolean", $bCountColors, "struct*", $tColors)[0] If $hBitmap = 0 Then Return SetError(4, 0, 0) Return SetExtended($tColors.cc, $hBitmap) EndFunc ;==>WebP_BitmapCreateGDIpFromMem ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_CreateWebPLossySimpleFromBitmap ; Description ...: Converts a GDI+ bitmap to WebP lossy image and save it to HD ; Syntax ........: WebP_CreateWebPLossySimpleFromBitmap($sFilename, $hBitmap[, $iQuality = 75[, $sPath2DLL = ""]]) ; Parameters ....: $sFilename - file to load ; $hBitmap - GDIPlus bitmap handle ; $iQuality - [optional] an integer value. Default is 75. Valid range is 0 - 100. ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir. ; Return values .: 1 on success, otherwise error -> -1 to -4 ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://developers.google.com/speed/webp ; Example .......: No ; =============================================================================================================================== Func WebP_CreateWebPLossySimpleFromBitmap($sFilename, $hBitmap, $iQuality = 75, $sPath2DLL = "") If $sFilename = "" Then Return SetError(1, 0, 0) Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(2, 0, 0) ;DLL not found Local $iReturn = DllCall($sDLL, "long", "WebP_CreateWebPLossySimpleFromBitmap", "str", $sFilename, "ptr", $hBitmap, "float", $iQuality)[0] If $iReturn = 0 Then Return SetError(3, 0, 0) Return 1 EndFunc ;==>WebP_CreateWebPLossySimpleFromBitmap ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_CreateWebPLosslessSimpleFromBitmap ; Description ...: Converts a GDI+ bitmap to WebP lossless image and save it to HD ; Syntax ........: WebP_CreateWebPLosslessSimpleFromBitmap($sFilename, $hBitmap[, $sPath2DLL = ""]) ; Parameters ....: $sFilename - file to load ; $hBitmap - GDIPlus bitmap handle ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir. ; Return values .: 0 for failure, 1 for success. ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://developers.google.com/speed/webp ; Example .......: No ; =============================================================================================================================== Func WebP_CreateWebPLosslessSimpleFromBitmap($sFilename, $hBitmap, $sPath2DLL = "") If $sFilename = "" Then Return SetError(1, 0, 0) Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(2, 0, 0) ;DLL not found Local $iReturn = DllCall($sDLL, "long", "WebP_CreateWebPLosslessSimpleFromBitmap", "str", $sFilename, "ptr", $hBitmap)[0] If $iReturn = 0 Then Return SetError(3, 0, 0) Return 1 EndFunc ;==>WebP_CreateWebPLosslessSimpleFromBitmap ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_CreateWebPAdvancedFromBitmap ; Description ...: Converts a bitmap to WebP lossy / lossless image and save it to HD ; Syntax ........: WebP_CreateWebPAdvancedFromBitmap($sFilename, $hBitmap[, $lossless = 0[, $quality = 75.0[, $method = 4[, ; $sns_strength = 50[, $filter_sharpness = 0[, $filter_strength = 60[, $pass = 6[, $near_lossless = 100[, ; $alpha_compression = 1[, $alpha_filtering = 1[, $alpha_quality = 100[, $target_size = 0[, ; $WebPImageHint = $WEBP_HINT_DEFAULT[, $NoSave = False[, $sPath2DLL = ""]]]]]]]]]]]]]]]) ; Parameters ....: $sFilename - a string value. ; $hBitmap - a handle value. ; $lossless - [optional] an unknown value. Default is 0. ; $quality - [optional] an unknown value. Default is 75.0. ; $method - [optional] a map. Default is 4. ; $sns_strength - [optional] a string value. Default is 50. ; $filter_sharpness - [optional] a floating point value. Default is 0. ; $filter_strength - [optional] a floating point value. Default is 60. ; $pass - [optional] a pointer value. Default is 6. ; $near_lossless - [optional] a general number value. Default is 100. ; $alpha_compression - [optional] an array of unknowns. Default is 1. ; $alpha_filtering - [optional] an array of unknowns. Default is 1. ; $alpha_quality - [optional] an array of unknowns. Default is 100. ; $target_size - [optional] a dll struct value. Default is 0. ; $WebPImageHint - [optional] an unknown value. Default is $WEBP_HINT_DEFAULT. ; $NoSave - [optional] an unknown value. Default is False. ; $sPath2DLL - [optional] a string value. Default is "". ; Return values .: negative value up to -8 for failure, 1 for success or the struct with information (pointers, size) if $NoSave = True ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://developers.google.com/speed/webp ; Example .......: No ; =============================================================================================================================== Func WebP_CreateWebPAdvancedFromBitmap($sFilename, $hBitmap, $lossless = 0, $quality = 75.0, $method = 4, $sns_strength = 50, _ $filter_sharpness = 0, $filter_strength = 60, $pass = 6, $near_lossless = 100, $alpha_compression = 1, $alpha_filtering = 1, $alpha_quality = 100, _ $target_size = 0, $WebPImageHint = $WEBP_HINT_DEFAULT, $NoSave = False, $sPath2DLL = "") If $sFilename = "" And Not $NoSave Then Return SetError(1, 0, 0) Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(2, 0, 0) ;DLL not found Local $tMem = DllStructCreate("struct;ptr pPic; ptr pWriter; ptr pMemData; uint memsize;endstruct") Local $tWebPConfig = DllStructCreate($tagWebPConfig) FilltWebPConfigWithDefaults($tWebPConfig) With $tWebPConfig .lossless = $lossless .quality = ($quality < 0) ? 0 : (($quality > 100) ? 100 : $quality) .method = ($method < 0) ? 0 : (($method > 6) ? 6 : $method) .image_hint = ($WebPImageHint < 0) ? 0 : (($WebPImageHint > 4) ? 4 : $WebPImageHint) .target_size = $target_size ;in bytes .sns_strength = ($sns_strength < 0) ? 0 : (($sns_strength > 100) ? 100 : $sns_strength) .filter_strength = ($filter_strength < 0) ? 0 : (($filter_strength > 100) ? 100 : $filter_strength) .filter_sharpness = ($filter_sharpness < 0) ? 0 : (($filter_sharpness > 7) ? 7 : $filter_sharpness) .alpha_compression = $alpha_compression .alpha_filtering = ($alpha_filtering < 0) ? 0 : (($alpha_filtering > 2) ? 2 : $alpha_filtering) .alpha_quality = ($alpha_quality < 0) ? 0 : (($alpha_quality > 100) ? 100 : $alpha_quality) .pass = ($pass < 0) ? 0 : (($pass > 10) ? 10 : $pass) .near_lossless = ($near_lossless < 0) ? 0 : (($near_lossless > 100) ? 100 : $near_lossless) .exact = BitAND($near_lossless = 0, $lossless = 1) ? 1 : 0 EndWith Local $iReturn = DllCall($sDLL, "long", "WebP_CreateWebPAdvancedFromBitmap", _ "str", $sFilename, _ ;Webp filename "ptr", $hBitmap, _ ;handle to GDI+ bitmap "struct*", $tWebPConfig, _ ;WebP config settings "bool", $NoSave, _ "struct*", $tMem)[0] If $iReturn < 0 Then Return SetError(3, 0, $iReturn) If $NoSave And $tMem.memsize = 0 Then SetError(4, 0, 0) Return $NoSave ? $tMem : $iReturn EndFunc ;==>WebP_CreateWebPAdvancedFromBitmap ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_FreeUp ; Description ...: Release the ressources from $tMem struct ; Syntax ........: WebP_FreeUp(Byref $tMem[, $sPath2DLL = ""]) ; Parameters ....: $tMem - [in/out] a dll struct value. ; $sPath2DLL - [optional] a string value. Default is "". ; Return values .: 1 ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://developers.google.com/speed/webp ; Example .......: No ; =============================================================================================================================== Func WebP_FreeUp(ByRef $tMem, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found Local $iReturn = DllCall($sDLL, "long", "WebP_FreeUp", "struct*", $tMem)[0] Return $iReturn EndFunc ;==>WebP_FreeUp ; #FUNCTION# ==================================================================================================================== ; Name ..........: BitmapCountColors ; Description ...: Counts the colors used by the bitmap ; Syntax ........: BitmapCountColors($hBitmap) ; Parameters ....: $hBitmap - a handle to a GDI+ bitmap. ; $bGDIImage - [optional] a boolean value. Default is False (GDIPlus bitmap handle). ; Return values .: Number of colors used by the image. ; Author ........: UEZ ; Modified ......: ; Remarks .......: The result may differ from other programs for JPG images depending on the decoder. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func BitmapCountColors($hBitmap = 0, $bGDIImage = False, $sPath2DLL = "") If IsPtr($hBitmap) = 0 Or $hBitmap = 0 Then SetError(1, 0, 0) Local Const $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(2, 0, 0) ;DLL not found Local $iReturn = DllCall($sDLL, "ulong", "BitmapCountColors", "ptr", $hBitmap)[0] If Not $iReturn Or @error Then Return SetError(3, 0, 0) Return $iReturn EndFunc ;==>BitmapCountColors ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_ExtractAnimFramesToDisk ; Description ...: Extracts the frames of a WebP animated file ; Syntax ........: WebP_ExtractAnimFramesToDisk($sFile, $sDestPath = ""[, $sOutputFormat = "webp"[, $sPath2DLL = ""]]) ; Parameters ....: $sFilename - path to webp anim file. ; $sDestPath - destination folder. If empty then script path will be used. ; $sOutputFormat - [optional] a string value. Default is "webp". Any GDI+ supported or WebP image format. ; $sPath2DLL - [optional] a string value. Default is "". ; Return values .: number of extracted frames on success, otherwise error -> -1 to -3 ; Author ........: UEZ ; Modified ......: ; Remarks .......: If output image format is WebP then frames will be saved lossless. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_ExtractAnimFramesToDisk($sFilename, $sDestPath = "", $sOutputFormat = "webp", $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found Local Const $iResult = DllCall($sDLL, "long", "WebP_ExtractAnimFramesToDisk", "str", $sFilename, "str", $sDestPath, "str", StringStripWS($sOutputFormat, $STR_STRIPALL))[0] If $iResult < 1 Then Return SetError(2, 0, $iResult) Return $iResult EndFunc ;==>WebP_ExtractAnimFramesToDisk ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_GetAmountOfAnimFrames ; Description ...: Get the amount of frames from an animated webp file ; Syntax ........: WebP_GetAmountOfAnimFrames($sFilename[, $sPath2DLL = ""]) ; Parameters ....: $sFilename - path to webp anim file. ; $sPath2DLL - [optional] a string value. Default is "". ; Return values .: 0 for failure, otherwise the amount of frames ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_GetAmountOfAnimFrames($sFilename, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found Local Const $iResult = DllCall($sDLL, "uint", "WebP_GetAmountOfAnimFrames", "str", $sFilename)[0] If Not $iResult Or @error Then Return SetError(2, 0, 0) Return $iResult EndFunc ;==>WebP_GetAmountOfAnimFrames ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_ExtractAnimFramesToMem ; Description ...: Extracts all frames from a webp animated file to the memory ; Syntax ........: WebP_ExtractAnimFramesToMem($sFilename, Byref $iUB[, $sPath2DLL = ""]) ; Parameters ....: $sFilename - path to webp anim file. ; $iUB - [in/out] an integer value. Needed to save the amount of data in struct array -> frames * 2 ; $sPath2DLL - [optional] a string value. Default is "". ; Return values .: 0 for failure, otherwise struct array with pointer to the GDI+ image and frame delay ; Author ........: UEZ ; Modified ......: ; Remarks .......: You must dispose all frames when done. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_ExtractAnimFramesToMem($sFilename, ByRef $iUB, $bDither = False, $iDitherStrength = 32, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found Local $iFrames = WebP_GetAmountOfAnimFrames($sFilename, $sPath2DLL) If Not $iFrames Or @error Then Return SetError(2, 0, 0) Local $tImgPtr = DllStructCreate((@AutoItX64 ? "int64 array[" : "int array[") & $iFrames * 2 + 2 & "]") Local Const $iResult = DllCall($sDLL, "long", "WebP_ExtractAnimFramesToMem", "str", $sFilename, "ptr*", DllStructGetPtr($tImgPtr), "boolean", $bDither, "ubyte", $iDitherStrength)[0] If $iResult < 1 Or @error Then Return SetError(4, $iResult, 0) $iUB = $iFrames * 2 Return $tImgPtr EndFunc ;==>WebP_ExtractAnimFramesToMem ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_CreateWebPCreateAnim ; Description ...: Creates an WebP animation file ; Syntax ........: WebP_CreateWebPCreateAnim($aFilenames, $sOutfile[, $quality = 75.0[, $lossless = 0[, $method = 4[, ; $filter_strength = 60[, $sns_strength = 50[, $pass = 6[, $filter_sharpness = 0[, ; $near_lossless = 100[, $alpha_compression = 1[, $alpha_filtering = 1[, $alpha_quality = 100[, ; $target_size = 0[, $loop_count = 0[, $WebPImageHint = $WEBP_HINT_DEFAULT[, $iDefaultDelay = 75[, ; $pCallback = 0[, $sPath2DLL = ""]]]]]]]]]]]]]]]]]) ; Parameters ....: $aFilenames - an 2D array of pathes to the image files and delay per frame. ; $sOutfile - filename of WebP animation output file. ; $quality - [optional] an unknown value. Default is 75.0. Valid range is 0 - 100. ; $lossless - [optional] an unknown value. Default is 0. 0 for lossy encoding / 1 for lossless. ; $method - [optional] a map. Default is 4. Valid range is 0 - 6 (0=fast, 6=slower-better). ; $filter_strength - [optional] a floating point value. Default is 60. Range: [0 = off .. 100 = strongest] ; $sns_strength - [optional] a string value. Default is 50. Spatial Noise Shaping. 0=off, 100=maximum ; $pass - [optional] a pointer value. Default is 1. Number of entropy-analysis passes (in [1..10]). ; $filter_sharpness - [optional] a floating point value. Default is 0. Range: [0 = off .. 7 = least sharp] ; $near_lossless - [optional] a general number value. Default is 0 Near lossless encoding [0 = max loss .. 100 = off (default)]. ; $alpha_compression - [optional] an array of unknowns. Default is 1. Algorithm for encoding the alpha plane (0 = none,1 = compressed with WebP lossless). Default is 1. ; $alpha_filtering - [optional] an array of unknowns. Default is 1. Predictive filtering method for alpha plane.0: none, 1: fast, 2: best. Default if 1. ; $alpha_quality - [optional] an array of unknowns. Default is 100. Between 0 (smallest size) and 100 (lossless). Default is 100. ; $target_size - [optional] a dll struct value. Default is 0. If non-zero, set the desired target size in bytes. ; $loop_count - [optional] an unknown value. Default is 0. 0 = endless. ; $WebPImageHint - [optional] an unknown value. Default is $WEBP_HINT_DEFAULT. ; $iDefaultDelay - [optional] an integer value. Default is 75. Delay in milli seconds. ; $pCallback - [optional] a pointer value. Default is 0. Pointer to a callback address for progress hook. ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir. ; Return values .: 1 on success, otherwise error -> -1 to -12 ; Author ........: UEZ ; Modified ......: ; Remarks .......: All frames must have same image dimension. First image defines the dimension of the animation. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_CreateWebPCreateAnim($aFilenames, $sOutfile, $quality = 75.0, $lossless = 1, $method = 4, $filter_strength = 60, $sns_strength = 50, _ $pass = 1, $filter_sharpness = 0, $near_lossless = 0, $alpha_compression = 1, $alpha_filtering = 1, $alpha_quality = 100, _ $target_size = 0, $loop_count = 0, $WebPImageHint = $WEBP_HINT_DEFAULT, $iDefaultDelay = 75, $pCallback = 0, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found If $sOutfile = "" Then Return SetError(2, 0, 0) If Not IsArray($aFilenames) Or UBound($aFilenames) < 2 Then Return SetError(3, 0, 0) Local $iNumberOfFrames = UBound($aFilenames), $i Local $tArrayFrames = DllStructCreate("ptr ptr[" & $iNumberOfFrames & "]"), $tArrayFramesDelay = DllStructCreate("uint delay[" & $iNumberOfFrames & "]") Local $tArrayAnim[$iNumberOfFrames], $tArrayFrameDelay[$iNumberOfFrames], $aDim, $iW, $iH For $i = 0 To $iNumberOfFrames - 1 If Not FileExists($aFilenames[$i][0]) Then Return SetError(4, 0, 0) $tArrayAnim[$i] = DllStructCreate("char path[" & StringLen($aFilenames[$i][0]) + 1 & "]") $tArrayAnim[$i].path = $aFilenames[$i][0] $tArrayFrames.ptr(($i + 1)) = DllStructGetPtr($tArrayAnim[$i]) $tArrayFramesDelay.delay(($i + 1)) = (UBound($aFilenames, 2) ? ($aFilenames[$i][1] > 0 ? $aFilenames[$i][1] : $iDefaultDelay) : $iDefaultDelay) Next Local $tAnim = DllStructCreate("ptr pFrames;ptr pDelays") $tAnim.pFrames = DllStructGetPtr($tArrayFrames) $tAnim.pDelays = DllStructGetPtr($tArrayFramesDelay) If StringRight($sOutfile, 5) <> ".webp" Then $sOutfile &= ".webp" $loop_count = $loop_count < 0 ? 0 : $loop_count Local $tWebPConfig = DllStructCreate($tagWebPConfig) FilltWebPConfigWithDefaults($tWebPConfig) With $tWebPConfig .lossless = $lossless .quality = ($quality < 0) ? 0 : (($quality > 100) ? 100 : $quality) .method = ($method < 0) ? 0 : (($method > 6) ? 6 : $method) .image_hint = ($WebPImageHint < 0) ? 0 : (($WebPImageHint > 4) ? 4 : $WebPImageHint) .target_size = $target_size ;in bytes .sns_strength = ($sns_strength < 0) ? 0 : (($sns_strength > 100) ? 100 : $sns_strength) .filter_strength = ($filter_strength < 0) ? 0 : (($filter_strength > 100) ? 100 : $filter_strength) .filter_sharpness = ($filter_sharpness < 0) ? 0 : (($filter_sharpness > 7) ? 7 : $filter_sharpness) .alpha_compression = $alpha_compression .alpha_filtering = ($alpha_filtering < 0) ? 0 : (($alpha_filtering > 2) ? 2 : $alpha_filtering) .alpha_quality = ($alpha_quality < 0) ? 0 : (($alpha_quality > 100) ? 100 : $alpha_quality) .pass = ($pass < 0) ? 0 : (($pass > 10) ? 10 : $pass) .near_lossless = ($near_lossless < 0) ? 0 : (($near_lossless > 100) ? 100 : $near_lossless) EndWith Local $iReturn = DllCall($sDLL, "long", "WebP_CreateWebPCreateAnim", _ "struct*", $tAnim, _ ;array of filenames with GDi+ supported images and delay per frame "uint", $iNumberOfFrames, _ ;amount of frames "str", $sOutfile, _ ;output filename "long", $loop_count, _ ;loop count -> 0 = endless "struct*", $tWebPConfig, _ ;WebP config settings "ptr", $pCallback)[0] ;callback pointer for progress status If $iReturn < 1 Then Return SetError(7, 0, $iReturn) ReDim $tArrayAnim[0] ReDim $tArrayFrameDelay[0] Return 1 EndFunc ;==>WebP_CreateWebPCreateAnim ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_CreateWebPCreateAnimFromScreenCapture ; Description ...: Capture the screen to WebP animation file ; Syntax ........: WebP_CreateWebPCreateAnimFromScreenCapture($x, $y, $w, $h, $sec, $sOutfile[, $fps = 30[, $CapCursor = 1[, ; $quality = 75.0[, $lossless = 0[, $method = 0[, $filter_strength = 60[, $sns_strength = 50[, $pass = 1[, ; $level = 6[, $filter_sharpness = 0[, $near_lossless = 100[, $alpha_compression = 0[, ; $alpha_filtering = 0[, $alpha_quality = 100[, $target_size = 0[, $loop_count = 0[, ; $WebPPreset = $WEBP_HINT_DEFAULT[, $pCallback = 0[, $sPath2DLL = ""]]]]]]]]]]]]]]]]]]]) ; Parameters ....: $x - x position on the screen where to start the capturing. ; $y - y position on the screen where to start the capturing. ; $w - width of the screen to capture. ; $h - height of the screen to capture. ; $sec - seconds to capture ; $sOutfile - filename of WebP animation output file. ; $fps - [optional] a floating point value. Default is 30 fps. ; $CapCursor - [optional] an unknown value. Default is 1. ; $quality - [optional] an unknown value. Default is 75.0. Valid range is 0 - 100. ; $lossless - [optional] an unknown value. Default is 0. 0 for lossy encoding / 1 for lossless. ; $method - [optional] a map. Default is 0. Valid range is 0 - 6 (0=fast, 6=slower-better). ; $filter_strength - [optional] a floating point value. Default is 60. Range: [0 = off .. 100 = strongest] ; $sns_strength - [optional] a string value. Default is 50. Spatial Noise Shaping. 0=off, 100=maximum ; $pass - [optional] a pointer value. Default is 1. Number of entropy-analysis passes (in [1..10]). ; $filter_sharpness - [optional] a floating point value. Default is 0. Range: [0 = off .. 7 = least sharp] ; $near_lossless - [optional] a general number value. Default is 100. Near lossless encoding [0 = max loss .. 100 = off (default)]. ; $alpha_compression - [optional] an array of unknowns. Default is 0. Algorithm for encoding the alpha plane (0 = none,1 = compressed with WebP lossless). Default is 1. ; $alpha_filtering - [optional] an array of unknowns. Default is 0. Predictive filtering method for alpha plane.0: none, 1: fast, 2: best. Default if 1. ; $alpha_quality - [optional] an array of unknowns. Default is 100. Between 0 (smallest size) and 100 (lossless). Default is 100. ; $target_size - [optional] a dll struct value. Default is 0. If non-zero, set the desired target size in bytes. ; $loop_count - [optional] an unknown value. Default is 0. 0 = endless. ; $WebPImageHint - [optional] an unknown value. Default is $WEBP_HINT_DEFAULT. ; $pCallback - [optional] a pointer value. Default is 0. Callback pointer for progress status ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir. ; Return values .: 1 on success, otherwise error -> -1 to -9 ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_CreateWebPCreateAnimFromScreenCapture($x, $y, $w, $h, $sec, $sOutfile, $fps = 30, $CapCursor = 1, $quality = 75.0, $lossless = 0, $method = 0, $filter_strength = 60, $sns_strength = 50, _ $pass = 1, $filter_sharpness = 0, $near_lossless = 100, $alpha_compression = 0, $alpha_filtering = 0, $alpha_quality = 100, $target_size = 0, $loop_count = 0, _ $WebPImageHint = $WEBP_HINT_DEFAULT, $pCallback = 0, $sPath2DLL = "") If $w < 1 Or $h < 1 Or $fps < 1 Or $sec < 1 Then Return SetError(1, 0, 0) Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(2, 0, 0) ;DLL not found $loop_count = $loop_count < 0 ? 0 : $loop_count Local $tWebPConfig = DllStructCreate($tagWebPConfig) FilltWebPConfigWithDefaults($tWebPConfig) With $tWebPConfig .lossless = $lossless .quality = ($quality < 0) ? 0 : (($quality > 100) ? 100 : $quality) .method = ($method < 0) ? 0 : (($method > 6) ? 6 : $method) .image_hint = ($WebPImageHint < 0) ? 0 : (($WebPImageHint > 4) ? 4 : $WebPImageHint) .target_size = $target_size ;in bytes .sns_strength = ($sns_strength < 0) ? 0 : (($sns_strength > 100) ? 100 : $sns_strength) .filter_strength = ($filter_strength < 0) ? 0 : (($filter_strength > 100) ? 100 : $filter_strength) .filter_sharpness = ($filter_sharpness < 0) ? 0 : (($filter_sharpness > 7) ? 7 : $filter_sharpness) .alpha_compression = $alpha_compression .alpha_filtering = ($alpha_filtering < 0) ? 0 : (($alpha_filtering > 2) ? 2 : $alpha_filtering) .alpha_quality = ($alpha_quality < 0) ? 0 : (($alpha_quality > 100) ? 100 : $alpha_quality) .pass = ($pass < 0) ? 0 : (($pass > 10) ? 10 : $pass) .near_lossless = ($near_lossless < 0) ? 0 : (($near_lossless > 100) ? 100 : $near_lossless) EndWith Local $iReturn = DllCall($sDLL, "long", "WebP_CreateWebPCreateAnimFromScreenCapture", _ "long", $x, _ ;x position of the screen "long", $y, _ ;y position of the screen "ulong", $w, _ ;width of the screen to capture "ulong", $h, _ ;height of the screen to capture "long", $sec, _ ;duration in seconds "ushort", $fps, _ ;fps for capturing "str", $sOutfile, _ ;output file name "ubyte", $CapCursor, _ ;capture cursor "long", $loop_count, _ ;loop count -> 0 = endless. "struct*", $tWebPConfig, _ ;WebP config settings "ptr", $pCallback)[0] ;callback pointer for progress status If $iReturn < 1 Then Return SetError(3, 0, $iReturn) Return 1 EndFunc ;==>WebP_CreateWebPCreateAnimFromScreenCapture ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_ConvertGIF2WebP ; Description ...: Converts a GIF animation to WebP animation ; Syntax ........: WebP_ConvertGIF2WebP($sGIFAnimFile, $sOutWebPFile[, $quality = 75.0[, $lossless = 1[, $method = 6[, ; $filter_strength = 60[, $sns_strength = 50[, $pass = 10[, $filter_sharpness = 0[, ; $near_lossless = 100[, $alpha_compression = 1[, $alpha_filtering = 1[, $alpha_quality = 100[, ; $target_size = 0[, $loop_count = 0[, $WebPPreset = $WEBP_HINT_DEFAULT[, $pCallback = 0[, ; $sPath2DLL = ""]]]]]]]]]]]]]]]]) ; Parameters ....: $sGIFAnimFile - a string value. ; $sOutWebPFile - a string value. ; $quality - [optional] an unknown value. Default is 75.0. Valid range is 0 - 100. ; $lossless - [optional] an unknown value. Default is 1. 0 for lossy encoding / 1 for lossless. ; $method - [optional] a map. Default is 6. Valid range is 0 - 6 (0=fast, 6=slower-better). ; $filter_strength - [optional] a floating point value. Default is 60. Range: [0 = off .. 100 = strongest] ; $sns_strength - [optional] a string value. Default is 50. Spatial Noise Shaping. 0=off, 100=maximum ; $pass - [optional] a pointer value. Default is 10. Number of entropy-analysis passes (in [1..10]). ; $filter_sharpness - [optional] a floating point value. Default is 0. Range: [0 = off .. 7 = least sharp] ; $near_lossless - [optional] a general number value. Default is 100. Near lossless encoding [0 = max loss .. 100 = off (default)]. ; $alpha_compression - [optional] an array of unknowns. Default is 1. Algorithm for encoding the alpha plane (0 = none,1 = compressed with WebP lossless). Default is 1. ; $alpha_filtering - [optional] an array of unknowns. Default is 1. Predictive filtering method for alpha plane.0: none, 1: fast, 2: best. Default if 1. ; $alpha_quality - [optional] an array of unknowns. Default is 100. Between 0 (smallest size) and 100 (lossless). Default is 100. ; $target_size - [optional] a dll struct value. Default is 0. If non-zero, set the desired target size in bytes. ; $loop_count - [optional] an unknown value. Default is 0. 0 = endless. ; $WebPPreset - [optional] an unknown value. Default is $WEBP_HINT_DEFAULT. ; $pCallback - [optional] a pointer value. Default is 0. ; $sPath2DLL - [optional] a string value. Default is "". ; Return values .: 1 on success, otherwise error -> -1 to -11 ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_ConvertGIF2WebP($sGIFAnimFile, $sOutWebPFile, $quality = 75.0, $lossless = 1, $method = 6, $filter_strength = 60, $sns_strength = 50, _ $pass = 10, $filter_sharpness = 0, $near_lossless = 100, $alpha_compression = 1, $alpha_filtering = 1, $alpha_quality = 100, _ $target_size = 0, $loop_count = 0, $WebPImageHint = $WEBP_HINT_DEFAULT, $pCallback = 0, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found If $sOutWebPFile = "" Then Return SetError(2, 0, 0) If StringRight($sOutWebPFile, 5) <> ".webp" Then $sOutWebPFile &= ".webp" $loop_count = $loop_count < 0 ? 0 : $loop_count Local $tWebPConfig = DllStructCreate($tagWebPConfig) FilltWebPConfigWithDefaults($tWebPConfig) With $tWebPConfig .lossless = $lossless .quality = ($quality < 0) ? 0 : (($quality > 100) ? 100 : $quality) .method = ($method < 0) ? 0 : (($method > 6) ? 6 : $method) .image_hint = ($WebPImageHint < 0) ? 0 : (($WebPImageHint > 4) ? 4 : $WebPImageHint) .target_size = $target_size ;in bytes .sns_strength = ($sns_strength < 0) ? 0 : (($sns_strength > 100) ? 100 : $sns_strength) .filter_strength = ($filter_strength < 0) ? 0 : (($filter_strength > 100) ? 100 : $filter_strength) .filter_sharpness = ($filter_sharpness < 0) ? 0 : (($filter_sharpness > 7) ? 7 : $filter_sharpness) .alpha_compression = $alpha_compression .alpha_filtering = ($alpha_filtering < 0) ? 0 : (($alpha_filtering > 2) ? 2 : $alpha_filtering) .alpha_quality = ($alpha_quality < 0) ? 0 : (($alpha_quality > 100) ? 100 : $alpha_quality) .pass = ($pass < 0) ? 0 : (($pass > 10) ? 10 : $pass) .near_lossless = ($near_lossless < 0) ? 0 : (($near_lossless > 100) ? 100 : $near_lossless) EndWith Local $iReturn = DllCall($sDLL, "long", "WebP_ConvertGIF2WebP", _ "str", $sGIFAnimFile, _ ;GIF animated input file "str", $sOutWebPFile, _ ;WebP animation output file "long", $loop_count, _ ;loop count -> 0 = endless "struct*", $tWebPConfig, _ ;WebP config settings "ptr", $pCallback)[0] ;callback pointer for progress status If $iReturn < 1 Then Return SetError(3, 0, $iReturn) Return 1 EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_ConvertAPNG2WebP ; Description ...: Converts a PNG animation to WebP animation ; Syntax ........: WebP_ConvertAPNG2WebP($sAPNGAnimFile, $sOutWebPFile[, $quality = 75.0[, $lossless = 1[, $method = 5[, ; $filter_strength = 60[, $sns_strength = 50[, $pass = 10[, $filter_sharpness = 0[, ; $near_lossless = 100[, $alpha_compression = 1[, $alpha_filtering = 1[, $alpha_quality = 100[, ; $target_size = 0[, $loop_count = 0[, $WebPPreset = $WEBP_HINT_DEFAULT[, $iDefaultDelay = 50[, ; $pCallback = 0[, $sPath2DLL = ""]]]]]]]]]]]]]]]]]]) ; Parameters ....: $sAPNGAnimFile - a string value. ; $sOutWebPFile - a string value. ; $quality - [optional] an unknown value. Default is 75.0. Valid range is 0 - 100. ; $lossless - [optional] an unknown value. Default is 1. 0 for lossy encoding / 1 for lossless. ; $method - [optional] a map. Default is 6. Valid range is 0 - 6 (0=fast, 6=slower-better). ; $filter_strength - [optional] a floating point value. Default is 60. Range: [0 = off .. 100 = strongest] ; $sns_strength - [optional] a string value. Default is 50. Spatial Noise Shaping. 0=off, 100=maximum ; $pass - [optional] a pointer value. Default is 10. Number of entropy-analysis passes (in [1..10]). ; $filter_sharpness - [optional] a floating point value. Default is 0. Range: [0 = off .. 7 = least sharp] ; $near_lossless - [optional] a general number value. Default is 100. Near lossless encoding [0 = max loss .. 100 = off (default)]. ; $alpha_compression - [optional] an array of unknowns. Default is 1. Algorithm for encoding the alpha plane (0 = none,1 = compressed with WebP lossless). Default is 1. ; $alpha_filtering - [optional] an array of unknowns. Default is 1. Predictive filtering method for alpha plane.0: none, 1: fast, 2: best. Default if 1. ; $alpha_quality - [optional] an array of unknowns. Default is 100. Between 0 (smallest size) and 100 (lossless). Default is 100. ; $target_size - [optional] a dll struct value. Default is 0. If non-zero, set the desired target size in bytes. ; $loop_count - [optional] an unknown value. Default is 0. 0 = endless. ; $WebPPreset - [optional] an unknown value. Default is $WEBP_HINT_DEFAULT. ; $iDefaultDelay - [optional] an integer value. Default is 50. ; $pCallback - [optional] a pointer value. Default is 0. ; $sPath2DLL - [optional] a string value. Default is "". ; Return values .: 1 on success, otherwise error -> -1 to -13 ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_ConvertAPNG2WebP($sAPNGAnimFile, $sOutWebPFile, $quality = 75.0, $lossless = 1, $method = 6, $filter_strength = 60, $sns_strength = 50, _ $pass = 10, $filter_sharpness = 0, $near_lossless = 100, $alpha_compression = 1, $alpha_filtering = 1, $alpha_quality = 100, _ $target_size = 0, $loop_count = 0, $WebPImageHint = $WEBP_HINT_DEFAULT, $iDefaultDelay = 50, $pCallback = 0, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found If $sOutWebPFile = "" Then Return SetError(2, 0, 0) If StringRight($sOutWebPFile, 5) <> ".webp" Then $sOutWebPFile &= ".webp" $loop_count = $loop_count < 0 ? 0 : $loop_count Local $tWebPConfig = DllStructCreate($tagWebPConfig) FilltWebPConfigWithDefaults($tWebPConfig) With $tWebPConfig .lossless = $lossless .quality = ($quality < 0) ? 0 : (($quality > 100) ? 100 : $quality) .method = ($method < 0) ? 0 : (($method > 6) ? 6 : $method) .image_hint = ($WebPImageHint < 0) ? 0 : (($WebPImageHint > 4) ? 4 : $WebPImageHint) .target_size = $target_size ;in bytes .sns_strength = ($sns_strength < 0) ? 0 : (($sns_strength > 100) ? 100 : $sns_strength) .filter_strength = ($filter_strength < 0) ? 0 : (($filter_strength > 100) ? 100 : $filter_strength) .filter_sharpness = ($filter_sharpness < 0) ? 0 : (($filter_sharpness > 7) ? 7 : $filter_sharpness) .alpha_compression = $alpha_compression .alpha_filtering = ($alpha_filtering < 0) ? 0 : (($alpha_filtering > 2) ? 2 : $alpha_filtering) .alpha_quality = ($alpha_quality < 0) ? 0 : (($alpha_quality > 100) ? 100 : $alpha_quality) .pass = ($pass < 0) ? 0 : (($pass > 10) ? 10 : $pass) .thread_level = 1 .near_lossless = ($near_lossless < 0) ? 0 : (($near_lossless > 100) ? 100 : $near_lossless) EndWith $iDefaultDelay = ($iDefaultDelay < 0) ? 0 : $iDefaultDelay Local $iReturn = DllCall($sDLL, "long", "WebP_ConvertAPNG2WebP", _ "str", $sAPNGAnimFile, _ ;GIF animated input file "str", $sOutWebPFile, _ ;WebP animation output file "long", $loop_count, _ ;loop count -> 0 = endless "long", $iDefaultDelay, _ ;delay of each frame "struct*", $tWebPConfig, _ ;WebP config settings "ptr", $pCallback)[0] ;callback pointer for progress status If $iReturn < 1 Then Return SetError(3, 0, $iReturn) Return 1 EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_GetAnimFileInfo ; Description ...: Get information about a WebP anim file ; Syntax ........: WebP_GetAnimFileInfo($sFilename, Byref $tAnimInfo[, $sPath2DLL = ""]) ; Parameters ....: $sFilename - path to webp anim file. ; $tAnimInfo - [in/out] a dll struct value. Must be "ulong Width;ulong Height;ulong FrameCount;ulong Duration;double FPS" ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir. ; Return values .: 1 on success, otherwise error -> -1 to -6 ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_GetAnimFileInfo($sFilename, ByRef $tAnimInfo, $sPath2DLL = "") If Not FileExists($sFilename) Then Return SetError(1, 0, 0) Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(2, 0, 0) ;DLL not found Local $iReturn = DllCall($sDLL, "long", "WebP_GetAnimFileInfo", "str", $sFilename, "struct*", $tAnimInfo)[0] If @error Or $iReturn < 1 Then SetError(3, 0, $iReturn) Return $iReturn EndFunc ;==>WebP_GetAnimFileInfo ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_GetImagesDiffFromFile ; Description ...: Displays the difference of two WebP images. ; Syntax ........: WebP_GetImagesDiffFromFile($sFilename1, $sFilename2[, $iMetricType = 1[, $sPath2DLL = ""]]) ; Parameters ....: $sFilename1 - a string value. First WebP image filename. ; $sFilename2 - a string value. Second WebP image filename. ; $iMetricType - [optional] an integer value. Default is 1. Valid values 0 - 2. ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir. ; Return values .: array with distortion values, otherwise error ; Author ........: UEZ ; Modified ......: ; Remarks .......: Possible metric type: ; 0: PSNR - Peak signal-to-noise ratio - measures numerical deviation (higher = better). ; Value range Interpretation ; > 50 dB Excellent quality - barely visible ; 40-50 dB Very good quality ; 30-40 dB Good to medium quality ; < 30 dB Clearly visible losses ; 1: SSIM - Structural Similarity Index - takes visual perception into account (0 - 100, closer to 100 = better). ; Value range Interpretation ; 95 - 100 Almost identical / perfect quality ; 90 - 95 Very good quality ; 85 - 90 Good quality ; < 85 Visible structural differences ; 2: LSIM - Local Similarity - more detailed, for local differences (more experimental). Same as SSIM. ; ; Both images must have same dimension! ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_GetImagesDiffFromFile($sFilename1, $sFilename2, $iMetricType = 1, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found If Not FileExists($sFilename1) Then Return SetError(2, 0, 0) If Not FileExists($sFilename2) Then Return SetError(3, 0, 0) $iMetricType = ($iMetricType > 2) ? 2 : ($iMetricType < 0 ? 0 : $iMetricType) Local $tDistortion = DllStructCreate("float d[5]") Local $iReturn = DllCall($sDLL, "long", "WebP_GetImagesDiffFromFile", "str", $sFilename1, "str", $sFilename2, "long", $iMetricType, "ptr*", DllStructGetPtr($tDistortion))[0] If $iReturn < 1 Then SetError(4, 0, $iReturn) Local $aDistortion[5] = [$tDistortion.d((1)), $tDistortion.d((2)), $tDistortion.d((3)), $tDistortion.d((4)), $tDistortion.d((5))] Return $aDistortion EndFunc ;==>WebP_GetImagesDiffFromFile ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_ScaleImage ; Description ...: Resizes a WebP image. ; Syntax ........: WebP_ScaleImage($sSourceFile, $iW, $iH, $sDestFile[, $sPath2DLL = ""]) ; Parameters ....: $sSourceFile - source WebP file to load. ; $iW - an integer value. ; $iH - an integer value. ; $sDestFile - destination WebP file to save. ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir. ; Return values .: 1 on success, otherwise error -> -1 to -9 ; Author ........: UEZ ; Modified ......: ; Remarks .......: Resized image will be saved lossless. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_ScaleImage($sSourceFile, $iW, $iH, $sDestFile, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found Local $iReturn = DllCall($sDLL, "long", "WebP_ScaleImage", "str", $sSourceFile, "long", $iW, "long", $iH, "str", $sDestFile)[0] If $iReturn < 1 Then SetError(2, 0, $iReturn) Return 1 EndFunc ;==>WebP_ScaleImage ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_GetImageQuality ; Description ...: Estimates the quality of a WebP image. ; Syntax ........: WebP_GetImageQuality($sFilename[, $sPath2DLL = ""]) ; Parameters ....: $sFilename - source WebP file to load. ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir. ; Return values .: the quality of the WebP image. 0 - 100 for lossy - 101 for lossless. 0 or negative value on error. ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_GetImageQuality($sFilename, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found If Not FileExists($sFilename) Then Return SetError(2, 0, 0) Local $iReturn = DllCall($sDLL, "long", "WebP_GetImageQuality", "str", $sFilename)[0] If $iReturn < 0 Then SetError(3, 0, $iReturn) Return $iReturn EndFunc ;==>WebP_GetImageQuality ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_PlayAnimFile ; Description ...: Plays an animated WebP file and display it in the GUI ; Syntax ........: WebP_PlayAnimFile($sFilename, $hGUI[, $w = 0[, $h = 0[, $pCallback = 0[, $sPath2DLL = ""]]]]) ; Parameters ....: $sFilename - path to webp anim file. ; $hGUI - the handle to the GUI to copy the frames to it. ; $w - [optional] an unknown value. Default is 0. If 0 the width from the animation file will be used. ; $h - [optional] a handle value. Default is 0. If 0 the height from the animation file will be used. ; $pCallback - [optional] a pointer value. Default is 0. ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir. ; Return values .: a pointer to the thread on success, otherwise error -> 0 ; Author ........: UEZ ; Modified ......: ; Remarks .......: Don't use $pCallback yet because it is not working properly! Don't forget DllClose($g_hDLL) when done! DllOpen must be used otherwise crash. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_PlayAnimFile($sFilename, $hGUI, $w = 0, $h = 0, $pCallback = 0, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found If Not FileExists($sFilename) Then Return SetError(2, 0, 0) $g_hDLL = DllOpen($sDLL) Local $pReturn = DllCall($g_hDLL, "ptr", "WebP_PlayAnimFile", "str", $sFilename, "hwnd", HWnd($hGUI), "ulong", $w, "ulong", $h, "ptr", $pCallback)[0] If $pReturn = 0 Then SetError(3, 0, 0) Return $pReturn EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_StopAnimFile ; Description ...: Stops the animation which was started by WebP_PlayAnimFile() function. ; Syntax ........: WebP_StopAnimFile($pThread[, $sPath2DLL = ""]) ; Parameters ....: $pThread - a thread parameter pointer ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir. ; Return values .: 1 on success, otherwise error -> -1 ; Author ........: UEZ ; Modified ......: ; Remarks .......: You must call WebP_PlayAnimFile() before you call WebP_StopAnimFile()! Don't forget DllClose($g_hDLL) when done! ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_StopAnimFile($pThread, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found If Not $g_hDLL Then Return SetError(2, 0, 0) Local $iReturn = DllCall($g_hDLL, "long", "WebP_StopAnimFile", "ptr", $pThread)[0] If $iReturn < 1 Then SetError(3, 0, $iReturn) Return $iReturn EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WinAPI_MarkScreenRegion ; Description ...: Selected area on desktop will be captured and save to clipbord or GDI bitmap handle will be returned. ; Syntax ........: _WinAPI_MarkScreenRegion([$iFillMode = 0]) ; Parameters ....: $iFillMode - [optional] an integer value. Default is 0. ; 0: marked area filled with solid color ; 1: marked area filled with hatch pattern ($HS_DIAGCROSS) ; 2: marked area without any fill pattern / color - only red border ; Return values .: 0 / 1 / -1 / array with coordinates [x, y, w, h] ; Author ........: UEZ ; Version .......: 0.90 build 2025-06-27 ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: no ; =============================================================================================================================== Func _WinAPI_MarkScreenRegion($iFillMode = 0) If @OSBuild > 6299 Then ;https://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx DllCall("Shcore.dll", "long", "PROCESS_DPI_AWARENESS", 1) ;PROCESS_SYSTEM_DPI_AWARE = 1 (https://msdn.microsoft.com/en-us/library/windows/desktop/dn280512(v=vs.85).aspx) Else DllCall("User32.dll", "bool", "SetProcessDPIAware") EndIf Local $iOld = AutoItSetOption("MouseCoordMode", 1) Local Const $hDesktop = WinGetHandle("[TITLE:Program Manager;CLASS:Progman]") Local Const $aFullScreen = WinGetPos($hDesktop) ;should work also on multi screens Local Const $iW = $aFullScreen[2], $iH = $aFullScreen[3] Local Const $hGUI_MarkScreen = GUICreate("", $iW, $iH, $aFullScreen[0], $aFullScreen[1], $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED)) GUISetState(@SW_SHOW, $hGUI_MarkScreen) Local Const $hDC = _WinAPI_GetDC($hGUI_MarkScreen) Local Const $hGfxDC = _WinAPI_CreateCompatibleDC($hDC) Local Const $hBitmapGDI = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) Local $hObjOld = _WinAPI_SelectObject($hGfxDC, $hBitmapGDI) Local $tSize = DllStructCreate($tagSIZE) $tSize.x = $iW $tSize.y = $iH Local $tSource = DllStructCreate($tagPOINT) Local $tBlend = DllStructCreate($tagBLENDFUNCTION) $tBlend.Alpha = 0xFF $tBlend.Format = 1 Local $tDest = DllStructCreate($tagPOINT), $pPoint = DllStructGetPtr($tDest) $tDest.x = $aFullScreen[0] $tDest.y = $aFullScreen[1] Local Const $hPen = _WinAPI_CreatePen($PS_SOLID, 1, 0x0000FF) Local Const $hPen_Orig = _WinAPI_SelectObject($hGfxDC, $hPen) Local $hBrush, $iAlpha2, $iFlag $iFillMode = $iFillMode > 2 ? 2 : $iFillMode < 0 ? 0 : $iFillMode Switch $iFillMode Case 0 $hBrush = _WinAPI_CreateBrushIndirect($BS_SOLID, 0x808080) $iAlpha2 = 0xA0 $iFlag = $ULW_ALPHA Case 1 $hBrush = _WinAPI_CreateBrushIndirect($BS_HATCHED, 0x808000, $HS_DIAGCROSS) $iAlpha2 = 0x30 $iFlag = $ULW_ALPHA Case 2 $hBrush = _WinAPI_CreateBrushIndirect($BS_HOLLOW, 0x000000) $iAlpha2 = 0xFF ;not needed $iFlag = $ULW_COLORKEY EndSwitch Local $hBrush_Orig = _WinAPI_SelectObject($hGfxDC, $hBrush) Local $aMPos[5], $aMPos_old[4], $tRECT = _WinAPI_CreateRect(0, 0, 0, 0) Do GUISetCursor(16, 1, $hGUI_MarkScreen) $aMPos = GUIGetCursorInfo($hGUI_MarkScreen) $aMPos_old[0] = $aMPos[0] $aMPos_old[1] = $aMPos[1] $aMPos_old[2] = MouseGetPos(0) $aMPos_old[3] = MouseGetPos(1) Switch $aMPos[2] Case 0 ;display crosshair _WinAPI_BitBlt($hGfxDC, 0, 0, $iW, $iH, $hGfxDC, 0, 0, $CAPTUREBLT) _WinAPI_DrawLine($hGfxDC, $tDest.x, $aMPos[1], $iW, $aMPos[1]) _WinAPI_DrawLine($hGfxDC, $aMPos[0], $tDest.y, $aMPos[0], $iH) _WinAPI_UpdateLayeredWindow($hGUI_MarkScreen, $hDC, $tDest, $tSize, $hGfxDC, $tSource, 0, $tBlend, $ULW_COLORKEY) Case 1 ; $tBlend.Alpha = $iAlpha2 While $aMPos[2] ;mark region GUISetCursor(14, 1, $hGUI_MarkScreen) ;WinGetHandle(AutoItWinGetTitle())) $aMPos = GUIGetCursorInfo($hGUI_MarkScreen) _WinAPI_BitBlt($hGfxDC, 0, 0, $iW, $iH, $hGfxDC, 0, 0, $CAPTUREBLT) ;clear bitmap ;draw rectangle $tRECT.Left = $aMPos_old[0] $tRECT.Top = $aMPos_old[1] $tRECT.Right = $aMPos[0] $tRECT.Bottom = $aMPos[1] _WinAPI_Rectangle($hGfxDC, $tRECT) If $iFillMode <> 2 Then _WinAPI_InvertRect($hGfxDC, $tRECT) _WinAPI_UpdateLayeredWindow($hGUI_MarkScreen, $hDC, $tDest, $tSize, $hGfxDC, $tSource, 0, $tBlend, $iFlag) Sleep(10) WEnd _WinAPI_SelectObject($hGfxDC, $hObjOld) _WinAPI_ReleaseDC($hGUI_MarkScreen, $hDC) _WinAPI_DeleteDC($hGfxDC) _WinAPI_DeleteObject($hBitmapGDI) _WinAPI_SelectObject($hGfxDC, $hPen_Orig) _WinAPI_DeleteObject($hPen) _WinAPI_SelectObject($hGfxDC, $hBrush_Orig) _WinAPI_DeleteObject($hBrush) GUIDelete($hGUI_MarkScreen) AutoItSetOption("MouseCoordMode", $iOld) Local $aCoords[4] = [($aMPos[0] > $aMPos_old[2] ? $aMPos_old[2] : $aMPos[0]), ($aMPos[1] > $aMPos_old[3] ? $aMPos_old[3] : $aMPos[1]), Abs($tRECT.Right - $tRECT.Left) + 1, Abs($tRECT.Bottom - $tRECT.Top) + 1] Return $aCoords EndSwitch Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _WinAPI_SelectObject($hGfxDC, $hObjOld) _WinAPI_ReleaseDC($hGUI_MarkScreen, $hDC) _WinAPI_DeleteDC($hGfxDC) _WinAPI_DeleteObject($hBitmapGDI) _WinAPI_SelectObject($hGfxDC, $hPen_Orig) _WinAPI_DeleteObject($hPen) GUIDelete($hGUI_MarkScreen) AutoItSetOption("MouseCoordMode", $iOld) Return -1 EndSwitch Until False EndFunc ;==>_WinAPI_MarkScreenRegion ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: Path2DLL ; Description ...: Return the path to the _WebP_x??.dll ; Author ........: UEZ ; Modified.......: ; Remarks .......: This function is used internally by WebP.au3 ; =============================================================================================================================== Func Path2DLL($sPath2DLL = "") Return $sPath2DLL ? $sPath2DLL : @ScriptDir & (@AutoItX64 ? "\_WebP_x64.dll" : "\_WebP_x86.dll") EndFunc ;==>Path2DLL Func FilltWebPConfigWithDefaults(ByRef $tWebPConfig) With $tWebPConfig .lossless = 0 .quality = 75 .method = 4 .image_hint = 0 .target_size = 0 .target_PSNR = 0 .segments = 4 .sns_strength = 50 .filter_strength = 60 .filter_sharpness = 0 .filter_type = 1 .autofilter = 0 .alpha_compression = 1 .alpha_filtering = 1 .alpha_quality = 100 .pass = 1 .show_compressed = 0 .preprocessing = 0 .partitions = 0 .partition_limit = 0 .emulate_jpeg_size = 0 .thread_level = 0 .low_memory = 0 .near_lossless = 100 .exact = 0 .use_delta_palette = 0 .use_sharp_yuv = 0 .qmin = 0 .qmax = 100 EndWith EndFunc
-
I changed for unknown reason the Extern "Windows-MS" to Extern "Windows" which is causing the problem when running it as x86 because obviously some functions require __msfastcall convention instead of stdcall. Can you please check for the latest x86 version for the examples? Thanks!
-
Werty reacted to a post in a topic: DLL Call Problems
-
argumentum reacted to a post in a topic: DLL Call Problems
-
Made a quick test with 3.3.12.0 by replacing AutoIt3.exe only - same result.
-
pixelsearch reacted to a post in a topic: DLL Call Problems
-
It is very odd why it is not working with Autoit. In FB it is straight forward - nothing special.
-
You are lucky. I found a backup file which is dated to 0.4.4 but what is the reason for the request for the older version? V0.4.4 is uploaded to my 1drv.
-
The DLLs can be found also on my 1Drv where WebP stuff is hosted.