Jump to content

Search the Community

Showing results for tags 'processing'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 2 results

  1. I enhanced the Delaunay function in my _GDIPlus_BitmapApplyFilter Dll and created a front-end GUI to generate Low-Polygon images: Code: ;Coded by UEZ v0.70build 2026-02-20 ;Requires 3.3.15.0+ version #AutoIt3Wrapper_Version=p #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_HiDpi=y #include <Array.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <ScreenCapture.au3> #include <StaticConstants.au3> #include <WinAPIGdi.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> #include "_GDIPlus_BitmapApplyFilter.au3" Global Const $hDLL = _GDIPlus_BitmapApplyFilter_Open("c:\_BZ25LN\Coding\FreeBASIC\__UEZ\__Projects\_GDIPlus_BitmapApplyFilter\_GDIPlus_BitmapApplyFilter_x64.dll") Global Const $sVer = _GDIPlus_BitmapApplyFilter_Ver2() Global $tokenVer = StringRegExpReplace($sVer, "v(.+?)\h+.+", "$1") Global $tokenBuild = StringRegExpReplace($sVer, ".+build\h+(.+?)\hbeta", "$1") If Not CheckVer($tokenVer, "1.0.0") Or $tokenBuild < "2026-02-19" Then MsgBox(16, "Error", "Requires at least DLL v1.0.0 build 2026-02-19." & @CRLF & "Found: " & $sVer) Exit EndIf Global Const $hGUI = GUICreate("Low-Polygon Maker v0.71", 252, 906, @DesktopWidth - 260, 10, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_TOPMOST)) GUISetFont(8, 400, 0, "Consolas") GUISetBkColor(0xABCDEF, $hGUI) Global $iInp_x = 96, $iInp_w = 100, $y = 60, $y2 = 92, $p Global Const $iLbl_Title = GUICtrlCreateLabel("Low-Polygon Maker", 0, 8, 238, 32, $SS_CENTER) GUICtrlSetFont(-1, 18, 400, 0, "Consolas") Global Const $iLbl_EdgeDetection = GUICtrlCreateLabel("Edge Detection", 4, $y, 88, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iCombo_EdgeDetection = GUICtrlCreateCombo("", 96, $y - 4, 145, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") GUICtrlSetData($iCombo_EdgeDetection, "SOBEL|" & _ "SCHARR|" & _ "PREWITT|" & _ "SOVELVSPREWITT|" & _ "FREI_CHEN|" & _ "ROBINSON_COMPASS|" & _ "KAYYALI|" & _ "ROBERTS_CROSS|" & _ "RIDGE_DETECTION|" & _ "DIAGONAL_EDGES|" & _ "OUTLINE3X3|" & _ "LAPLACE3x3_1|" & _ "LAPLACE3x3_2|" & _ "LAPLACE5x5|" & _ "EDGE_DETECTION1|" & _ "EDGE_DETECTION2|" & _ "EDGE_DETECTION3|" & _ "EDGE_DETECTION4|" & _ "EDGE_DETECTION5|" & _ "EDGE_DETECTION6|" & _ "EMBOSS1|" & _ "EMBOSS2|" & _ "EMBOSS3|" & _ "EMBOSS4|" & _ "KIRSCH|" & _ "ISOTROPIC_SOBEL", _ "ROBERTS_CROSS") $y += 36 Global $aRet = _GDIPlus_BitmapCreateVerticalText("Coded by UEZ 2026", 21.75, "Consolas", 0x380000FF, 0x28000000, 2, 1) Global Const $iPic_Label = GUICtrlCreatePic("", 204, $y - 4, $aRet[1], $aRet[2]) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic_Label, $STM_SETIMAGE, $IMAGE_BITMAP, $aRet[0])) Global Const $iLbl_Threshold = GUICtrlCreateLabel("ED Threshold", 4, $y, 76, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iInp_Threshold = GUICtrlCreateInput(1.2, $iInp_x, $y2, $iInp_w, 21) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") GUICtrlSetTip(-1, "The lower the value, the larger the triangles.") Global Const $iLbl_Blur = GUICtrlCreateLabel("Blur Level", 4, $y + 1 * 32, 64, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iInp_Blur = GUICtrlCreateInput(1, $iInp_x, $y2 + 1 * 32, $iInp_w, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") Global Const $iLbl_Colors = GUICtrlCreateLabel("Max. Colors", 4, $y + 2 * 32, 70, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iInp_Colors = GUICtrlCreateInput(256, $iInp_x, $y2 + 2 * 32, $iInp_w, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") GUICtrlSetTip(-1, "Valid values are: 2, 16, 256") Global Const $iLbl_MinSpace = GUICtrlCreateLabel("Min Space", 4, $y + 3 * 32, 58, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iInp_MinSpace = GUICtrlCreateInput(8, $iInp_x, $y2 + 3 * 32, $iInp_w, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") Global Const $iLbl_MaxSpace = GUICtrlCreateLabel("Max Space", 4, $y + 4 * 32, 58, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iInp_MaxSpace = GUICtrlCreateInput(45, $iInp_x, $y2 + 4 * 32, $iInp_w, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") Global Const $iLbl_BorderSpaceX = GUICtrlCreateLabel("Border Space X", 4, $y + 5 * 32, 88, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iInp_BorderSpaceX = GUICtrlCreateInput(8, $iInp_x, $y2 + 5 * 32, $iInp_w, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") Global Const $iLbl_BorderSpaceY = GUICtrlCreateLabel("Border Space Y", 4, $y + 6 * 32, 88, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iInp_BorderSpaceY = GUICtrlCreateInput(8, $iInp_x, $y2 + 6 * 32, $iInp_w, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") Global Const $iLbl_Alpha = GUICtrlCreateLabel("Edges Alpha", 4, $y + 7 * 32, 70, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iInp_Alpha = GUICtrlCreateInput(24, $iInp_x, $y2 + 7 * 32, $iInp_w, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") Global Const $iLbl_PosterizeLvl = GUICtrlCreateLabel("Posterize Lvl", 4, $y + 8 * 32, 85, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iInp_PosterizeLvl = GUICtrlCreateInput(10, $iInp_x, $y2 + 8 * 32, $iInp_w, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") GUICtrlSetTip(-1, "When the posterization level is set, the value for 'Max. Colors' input is ignored.") Global Const $iLbl_Denoise = GUICtrlCreateLabel("Denoise Lvl", 4, $y + 9 * 32, 85, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iInp_DenoiseLvl = GUICtrlCreateInput(1, $iInp_x, $y2 + 9 * 32, $iInp_w, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") GUICtrlSetTip(-1, "The higher the value, the slower the operation.") Global Const $iLbl_EdgePoints = GUICtrlCreateLabel("Edge Points", 4, $y + 10 * 32, 85, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iInp_EdgePoints = GUICtrlCreateInput(16, $iInp_x, $y2 + 10 * 32, $iInp_w, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") GUICtrlSetTip(-1, "The lower the value, the more triangles.") Global Const $iLbl_CartoonRadius = GUICtrlCreateLabel("Cartoon Radius", 4, $y + 11 * 32, 85, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iInp_CartoonRadius = GUICtrlCreateInput(7, $iInp_x, $y2 + 11 * 32, $iInp_w, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") GUICtrlSetTip(-1, "The higher the value, the slower the operation.") Global Const $iLbl_CartoonIntens = GUICtrlCreateLabel("Cartoon Intens", 4, $y + 12 * 32, 85, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iInp_CartoonIntens = GUICtrlCreateInput(150.00, $iInp_x, $y2 + 12 * 32, $iInp_w, 21) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") $y2 += 102 $p = 10 Global Const $iChkB_ShowEdges = GUICtrlCreateCheckbox("Show Edges", 4, $y2 + $p * 32, 233, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") GUICtrlSetState(-1, $GUI_CHECKED) $p += 1 Global Const $iChkB_Wireframe = GUICtrlCreateCheckbox("Show Wireframes only", 4, $y2 + $p * 32, 233, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") $p += 1 Global Const $iChkB_GIFAnim = GUICtrlCreateCheckbox("Convert all GIF frames", 4, $y2 + $p * 32, 233, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") $p += 1 Global Const $iChkB_CartoonMode = GUICtrlCreateCheckbox("Enable Cartoon Mode", 4, $y2 + $p * 32, 233, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlSetTip(-1, "Very CPU intensive calculation.") $p += 1 Global Const $iChkB_AutoResize = GUICtrlCreateCheckbox("Resize large image to screen size", 4, $y2 + $p * 32, 233, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlSetTip(-1, "Large images are scaled to fit the screen size for faster processing, except GIF images.") $p += 1 $y2 += $p * 32 $p = 0 Global Const $iBtn_Apply = GUICtrlCreateButton("&Apply", 8, $y2 + $p * 72, 235, 57, $BS_DEFPUSHBUTTON) GUICtrlSetFont(-1, 12, 400, 0, "Consolas") GUICtrlSetBkColor(-1, 0xCCCCFF) GUICtrlSetState($iBtn_Apply, $GUI_DISABLE) $p += 1 Global Const $iBtn_Load = GUICtrlCreateButton("&Load Image", 8, $y2 + $p * 72, 235, 57) GUICtrlSetFont(-1, 12, 400, 0, "Consolas") GUICtrlSetBkColor(-1, 0xCCCCFF) $p += 1 Global Const $iBtn_Save = GUICtrlCreateButton("&Save Image", 8, $y2 + $p * 72, 235, 57) GUICtrlSetFont(-1, 12, 400, 0, "Consolas") GUICtrlSetBkColor(-1, 0xCCCCFF) GUICtrlSetState($iBtn_Save, $GUI_DISABLE) Global $aParts[1] = [-1] Global Const $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aParts, "Ready") Local $hFont = _WinAPI_CreateFont(12, 0, 0, 0, $FW_MEDIUM, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DRAFT_QUALITY, 0, "Segoe UI") _WinAPI_SetFont($hStatusBar, $hFont, True) GUISetState(@SW_SHOW) Global $aAccelKeys[4][2] = [["^s", $iBtn_Save], ["^l", $iBtn_Load], ["^a", $iBtn_Apply], ["{ENTER}", $iBtn_Apply]] GUISetAccelerators($aAccelKeys) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") GUIRegisterMsg($WM_DROPFILES, "_WM_DROPFILES") Global $aMsg, $hImage, $sImgFile, $hGUI_Display = 0, $hGDI_LowPoly, $sFileLowPoly, $g_iW, $g_iH, $hImgTmp = 0 ConsoleWrite("Screen: " & @DesktopWidth & "x" & @DesktopHeight & @CRLF) Dim $aFrameDelays[1], $aFramesGDI[1], $aFrames_LowPoly[1] Global $iCurrentFrame = 0, $iAnimFrameCount = 0, $bIsGIF, $iPic_LowPoly, $iSeed, $i, $r, $hImage_OrginalSize, $iDummy_Load = GUICtrlCreateDummy() While 1 $aMsg = GUIGetMsg(1) Switch $aMsg[1] Case $hGUI Switch $aMsg[0] Case $GUI_EVENT_CLOSE GUIRegisterMsg($WM_COMMAND, "") GUIRegisterMsg($WM_DROPFILES, "") AdlibUnRegister("PlayGIFAnimPreview") If $hGDI_LowPoly Then $r = MsgBox(BitOR($MB_ICONQUESTION, $MB_YESNO), "Question", "Save image before closing?", 5) If $r = $IDYES Then SaveImage() EndIf GUIDelete($hGUI) If UBound($aFrameDelays) > 1 Then For $i = 0 To UBound($aFramesGDI) - 1 _WinAPI_DeleteObject($aFramesGDI[$i]) Next For $i = 1 To $aFrames_LowPoly[0] _GDIPlus_ImageDispose($aFrames_LowPoly[$i]) Next EndIf If $hImage_OrginalSize Then _GDIPlus_ImageDispose($hImage_OrginalSize) If $hImgTmp Then _GDIPlus_ImageDispose($hImgTmp) _GDIPlus_BitmapApplyFilter_Close() Exit Case $iBtn_Load $sImgFile = FileOpenDialog("Select a GDI+ supported image", "", "Images (*.bmp;*.gif;*.png;*.jpg;*.tif)", $FD_FILEMUSTEXIST, "", $hGUI) If @error Then ContinueLoop If Not FileExists($sImgFile) Then MsgBox($MB_ICONERROR, "Error", $sImgFile & " doesn't exist", 30) ContinueLoop EndIf LoadImage($sImgFile) Case $iBtn_Save If $sImgFile = "" Or ($bIsGIF ? UBound($aFrames_LowPoly) < 2 : $hGDI_LowPoly = 0) Then ContinueLoop SaveImage() Case $iBtn_Apply If $sImgFile = "" Or $hImage = 0 Then ContinueLoop GUICtrlSetState($iBtn_Apply, $GUI_DISABLE) GUICtrlSetState($iBtn_Load, $GUI_DISABLE) GUICtrlSetState($iBtn_Save, $GUI_DISABLE) $iCurrentFrame = 0 EncodeAndDisplay($hImage) GUICtrlSetState($iBtn_Apply, $GUI_ENABLE) GUICtrlSetState($iBtn_Load, $GUI_ENABLE) GUICtrlSetState($iBtn_Save, $GUI_ENABLE) Case $iDummy_Load LoadImage($sImgFile) EndSwitch Case $hGUI_Display Switch $aMsg[0] Case $GUI_EVENT_CLOSE AdlibUnRegister("PlayGIFAnimPreview") GUIDelete($hGUI_Display) $hGUI_Display = 0 EndSwitch EndSwitch WEnd Func Min($a, $b) Return $a < $b ? $a : $b EndFunc ;==>Min Func Max($a, $b) Return $a > $b ? $a : $b EndFunc ;==>Max Func CalcResizeDim(ByRef $iW, ByRef $iH, $fFactor) Local $fScaleX, $fScaleY, $iMode = 0 If $iH > @DesktopHeight And $iW < @DesktopWidth + 1 Then $fScaleY = @DesktopHeight / $iH $iW *= $fScaleY $iH *= $fScaleY $iMode = 1 ElseIf $iH < @DesktopHeight + 1 And $iW > @DesktopWidth Then $fScaleX = @DesktopWidth / $iW $iW *= $fScaleX $iH *= $fScaleX $iMode = 2 ElseIf $iH > @DesktopHeight And $iW > @DesktopWidth Then If $iH > $iW Then $fScaleY = @DesktopHeight / $iH $iH *= $fScaleY $iW *= $fScaleY Else $fScaleX = @DesktopWidth / $iW $iH *= $fScaleX $iW *= $fScaleX EndIf $iMode = 3 EndIf If $iMode Or ($iW = @DesktopWidth Or $iH = @DesktopHeight) Then $iW *= $fFactor $iH *= $fFactor EndIf $iW = Int($iW) $iH = Int($iH) Return $iMode EndFunc Func EncodeAndDisplay($hImage, $ResizeInGUI = True) If $g_iW = 0 Or $g_iH = 0 Or $hImage = 0 Then Return SetError(1, 0, 0) Local $iW = $g_iW, $iH = $g_iH Local $fFactor = 0.925, $iMode = 0 If $ResizeInGUI Then $iMode = CalcResizeDim($iW, $iH, $fFactor) EndIf ConsoleWrite("Original: " & $g_iW & "x" & $g_iH & @CRLF) ConsoleWrite("Display: " & $iW & "x" & $iH & @CRLF) Static $iWp = 0, $iHp = 0 If ($iW <> $iWp Or $iH <> $iHp) Or $hGUI_Display = 0 Then If $hGUI_Display Then GUIDelete($hGUI_Display) $hGUI_Display = GUICreate("", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_OVERLAPPEDWINDOW) $iPic_LowPoly = GUICtrlCreatePic("", 0, 0, $iW - 1, $iH - 1, -1, $GUI_WS_EX_PARENTDRAG) GUISetState(@SW_SHOWNORMAL, $hGUI_Display) WinActivate($hGUI) EndIf $iWp = $iW $iHp = $iH If $hGDI_LowPoly Then _WinAPI_DeleteObject($hGDI_LowPoly) $hGDI_LowPoly = 0 ;~ ConsoleWrite("Blur level: " & Number(GUICtrlRead($iInp_Blur)) & @CRLF & _ ;~ "Kernel: " & Execute("$" & GUICtrlRead($iCombo_EdgeDetection)) & @CRLF & _ ;~ "Threshold: " & Number(GUICtrlRead($iInp_Threshold), $NUMBER_DOUBLE) & @CRLF & _ ;~ "Amount of Colors: " & Number(GUICtrlRead($iInp_Colors)) & @CRLF & _ ;~ "Min Space: " & Number(GUICtrlRead($iInp_MinSpace)) & @CRLF & _ ;~ "Max Space: " & Number(GUICtrlRead($iInp_MaxSpace)) & @CRLF & _ ;~ "Border Space X: " & Number(GUICtrlRead($iInp_BorderSpaceX)) & @CRLF & _ ;~ "Border Space Y: " & Number(GUICtrlRead($iInp_BorderSpaceY)) & @CRLF & _ ;~ "Show Edges Checked: " & Int(BitAND(GUICtrlRead($iChkB_ShowEdges), $GUI_CHECKED) = $GUI_CHECKED) & @CRLF & _ ;~ "Alpha Value: " & Number(GUICtrlRead($iInp_Alpha)) & @CRLF & _ ;~ "Wireframe Checked: " & Int(BitAND(GUICtrlRead($iChkB_Wireframe), $GUI_CHECKED) = $GUI_CHECKED) & @CRLF & _ ;~ "Posterize level: " & Number(GUICtrlRead($iInp_PosterizeLvl)) & @CRLF & _ ;~ "GIF Mode Checked: " & Int(BitAND(GUICtrlRead($iChkB_GIFAnim), $GUI_CHECKED) = $GUI_CHECKED) & @CRLF & _ ;~ "Posterize Lvl: " & Number(GUICtrlRead($iInp_PosterizeLvl)) & @CRLF & _ ;~ "Denoise Lvl: " & Number(GUICtrlRead($iInp_DenoiseLvl)) & @CRLF & _ ;~ "EdgePoints): " & Number(GUICtrlRead($iInp_EdgePoints)) & @CRLF & _ ;~ "CornerPoints: " & Number(GUICtrlRead($iInp_CornerPoints)) & @CRLF) ;~ ConsoleWrite("-----------------------------------------------------------------------" & @CRLF) AdlibUnRegister("PlayGIFAnimPreview") Local $i Local $iAnimDimCount = _GDIPlus_GIFAnimGetFrameDimensionsCount($hImage) Local $tGUID = _GDIPlus_GIFAnimGetFrameDimensionsList($hImage, $iAnimDimCount) $iAnimFrameCount = _GDIPlus_GIFAnimGetFrameCount($hImage, $tGUID) $aFrameDelays = _GDIPlus_GIFAnimGetFrameDelays($hImage, $iAnimFrameCount) If $iAnimFrameCount Then _GDIPlus_GIFAnimSelectActiveFrame($hImage, $tGUID, 0) _GUICtrlStatusBar_SetText($hStatusBar, "Calculation has started. Please wait...", 0, $SBT_POPOUT) ConsoleWrite("Image processing has started - please wait...") Local Const $fTimer = TimerInit() If Int(BitAND(GUICtrlRead($iChkB_GIFAnim), $GUI_CHECKED) = $GUI_CHECKED) And $bIsGIF And $iAnimFrameCount > 1 Then If UBound($aFramesGDI) > 1 Then For $i = 0 To UBound($aFramesGDI) - 1 _WinAPI_DeleteObject($aFramesGDI[$i]) _GDIPlus_ImageDispose($aFrames_LowPoly[$i + 1]) Next EndIf ReDim $aFramesGDI[$iAnimFrameCount] ReDim $aFrames_LowPoly[$iAnimFrameCount + 1] $aFrames_LowPoly[0] = $iAnimFrameCount For $i = 0 To $iAnimFrameCount - 1 _GDIPlus_GIFAnimSelectActiveFrame($hImage, $tGUID, $i) $aFrames_LowPoly[$i + 1] = _GDIPlus_BitmapApplyFilter_Delaunay3($hImage, _ Number(GUICtrlRead($iInp_Blur)), _ Execute("$" & GUICtrlRead($iCombo_EdgeDetection)), _ Number(GUICtrlRead($iInp_Threshold), $NUMBER_DOUBLE), _ Number(GUICtrlRead($iInp_Colors)), _ Number(GUICtrlRead($iInp_MinSpace)), _ Number(GUICtrlRead($iInp_MaxSpace)), _ Number(GUICtrlRead($iInp_BorderSpaceX)), _ Number(GUICtrlRead($iInp_BorderSpaceY)), _ Int(BitAND(GUICtrlRead($iChkB_ShowEdges), $GUI_CHECKED) = $GUI_CHECKED), _ Number(GUICtrlRead($iInp_Alpha)), _ Int(BitAND(GUICtrlRead($iChkB_Wireframe), $GUI_CHECKED) = $GUI_CHECKED), _ Number(GUICtrlRead($iInp_PosterizeLvl)), _ $iSeed, _ 0xFFFFFFFF, _ Number(GUICtrlRead($iInp_DenoiseLvl)), _ Number(GUICtrlRead($iInp_EdgePoints)), _ 50, _ Int(BitAND(GUICtrlRead($iChkB_CartoonMode), $GUI_CHECKED) = $GUI_CHECKED), _ Number(GUICtrlRead($iInp_CartoonRadius)), _ Number(GUICtrlRead($iInp_CartoonIntens), $NUMBER_DOUBLE), _ False) $aFramesGDI[$i] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($aFrames_LowPoly[$i + 1]) _GDIPlus_BitmapConvertTo8Bit($aFrames_LowPoly[$i + 1], 256, $GDIP_DitherTypeNone, $GDIP_PaletteTypeFixedHalftone256) ToolTip($i + 1 & "/" & $iAnimFrameCount & " : " & Round(($i + 1) / UBound($aFrameDelays) * 100, 2) & "%", MouseGetPos(0), MouseGetPos(1) + 30, "", 0, $TIP_CENTER) Next ToolTip("") AdlibRegister("PlayGIFAnimPreview", 10) Else $hGDI_LowPoly = _GDIPlus_BitmapApplyFilter_Delaunay3($hImage, _ Number(GUICtrlRead($iInp_Blur)), _ Execute("$" & GUICtrlRead($iCombo_EdgeDetection)), _ Number(GUICtrlRead($iInp_Threshold), $NUMBER_DOUBLE), _ Number(GUICtrlRead($iInp_Colors)), _ Number(GUICtrlRead($iInp_MinSpace)), _ Number(GUICtrlRead($iInp_MaxSpace)), _ Number(GUICtrlRead($iInp_BorderSpaceX)), _ Number(GUICtrlRead($iInp_BorderSpaceY)), _ Int(BitAND(GUICtrlRead($iChkB_ShowEdges), $GUI_CHECKED) = $GUI_CHECKED), _ Number(GUICtrlRead($iInp_Alpha)), _ Int(BitAND(GUICtrlRead($iChkB_Wireframe), $GUI_CHECKED) = $GUI_CHECKED), _ Number(GUICtrlRead($iInp_PosterizeLvl)), _ $iSeed, _ 0, _ Number(GUICtrlRead($iInp_DenoiseLvl)), _ Number(GUICtrlRead($iInp_EdgePoints)), _ 50, _ Int(BitAND(GUICtrlRead($iChkB_CartoonMode), $GUI_CHECKED) = $GUI_CHECKED), _ Number(GUICtrlRead($iInp_CartoonRadius)), _ Number(GUICtrlRead($iInp_CartoonIntens), $NUMBER_DOUBLE), _ True) If $hGDI_LowPoly = 0 Then GUIDelete($hGUI_Display) $hGUI_Display = 0 Return SetError(1, 0, 0) EndIf If $iMode Then ResizeImage($hGDI_LowPoly, $iW, $iH) Local $hHBmp = GUICtrlSendMsg($iPic_LowPoly, $STM_SETIMAGE, $IMAGE_BITMAP, $hGDI_LowPoly) If $hHBmp Then _WinAPI_DeleteObject($hHBmp) EndIf Local $fEnd = Round(TimerDiff($fTimer), 2) ConsoleWrite($fEnd & " ms." & @CRLF & @CRLF) _GUICtrlStatusBar_SetText($hStatusBar, "Generated in: " & $fEnd & " ms. Dimension: " & _GDIPlus_ImageGetWidth($hImage) & "x" & _GDIPlus_ImageGetHeight($hImage), 0, $SBT_POPOUT) _WinAPI_InvalidateRect($hGUI_Display) _WinAPI_RedrawWindow($hGUI_Display) EndFunc ;==>EncodeAndDisplay Func PlayGIFAnimPreview() AdlibUnRegister("PlayGIFAnimPreview") Local $iDelay = $aFrameDelays[$iCurrentFrame] Local Static $iTimerCurrentFrame = TimerInit() _WinAPI_DeleteObject(GUICtrlSendMsg($iPic_LowPoly, 0x0172, 0, $aFramesGDI[$iCurrentFrame])) ;$STM_SETIMAGE = 0x0172, $IMAGE_BITMAP = 0 If TimerDiff($iTimerCurrentFrame) > $iDelay Then $iCurrentFrame += 1 $iTimerCurrentFrame = TimerInit() EndIf If $iCurrentFrame > UBound($aFrameDelays) - 1 Then $iCurrentFrame = 0 AdlibRegister("PlayGIFAnimPreview", 10) EndFunc ;==>PlayGIFAnimPreview Func ResizeImage(ByRef $hBitmapGDI, $newW, $newH) Local $hImageCopy = _GDIPlus_BitmapCreateFromHBITMAP($hBitmapGDI) If $hImage_OrginalSize Then _GDIPlus_ImageDispose($hImage_OrginalSize) $hImage_OrginalSize = _GDIPlus_BitmapCloneArea($hImageCopy, 0, 0, $g_iW, $g_iH, $GDIP_PXF32ARGB) ;save original size of low-polygon image to save original size Local $hImageResized = _GDIPlus_ImageResize($hImageCopy, $newW, $newH) _WinAPI_DeleteObject($hBitmapGDI) $hBitmapGDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageResized, 0) _GDIPlus_ImageDispose($hImageResized) EndFunc ;==>ResizeImage Func LoadImage($sImgFile) If $hImage Then _GDIPlus_ImageDispose($hImage) $hImage = _GDIPlus_ImageLoadFromFile($sImgFile) If Not $hImage Then MsgBox($MB_ICONERROR, "Error", "Unable to load file to GDI+", 30) Return 0 EndIf $g_iW = _GDIPlus_ImageGetWidth($hImage) $g_iH = _GDIPlus_ImageGetHeight($hImage) $bIsGIF = False If StringRight($sImgFile, 4) = ".gif" Then $bIsGIF = True If $bIsGIF = False And Int(BitAND(GUICtrlRead($iChkB_AutoResize), $GUI_CHECKED) = $GUI_CHECKED) Then Local $iWt = $g_iW, $iHt = $g_iH, $iMode CalcResizeDim($iWt, $iHt, 1) If $iWt < $g_iW Or $iHt < $g_iH Then $hImgTmp = _GDIPlus_ImageResize($hImage, $iWt, $iHt) _GDIPlus_ImageDispose($hImage) $hImage = $hImgTmp ConsoleWrite("Original image " & $g_iW & "x" & $g_iH & " resized to " & $iWt & "x" & $iHt & @CRLF) $g_iW = _GDIPlus_ImageGetWidth($hImage) $g_iH = _GDIPlus_ImageGetHeight($hImage) EndIf EndIf $iSeed = Int(Random() * 0xFFFFFF) $iCurrentFrame = 0 $iAnimFrameCount = 0 Local $iMax = Int(Max($g_iW, $g_iH) / 192) If $iMax > 1 Then GUICtrlSetData($iInp_MinSpace, $iMax) GUICtrlSetData($iInp_MaxSpace, Ceiling($iMax * 4.5)) EndIf If $hImage Then GUICtrlSetState($iBtn_Apply, $GUI_ENABLE) GUICtrlSetState($iBtn_Save, $GUI_ENABLE) EndIf GUICtrlSetData($iInp_BorderSpaceX, Int($g_iW / 16)) GUICtrlSetData($iInp_BorderSpaceY, Int($g_iH / 16)) EncodeAndDisplay($hImage) EndFunc Func SaveImage() $sFileLowPoly = FileSaveDialog("Save Low-Polygone Image", "", "Images (*.bmp;*.gif;*.png;*.jpg;*.jpeg;*.tif;*.tiff)", 0, StringRegExpReplace($sImgFile, "^.*\\([^\\]+)(\.[^.]+)$", "\1_Low-Polygon\2"), $hGUI) If @error Or $sFileLowPoly = "" Then Return 0 If FileExists($sFileLowPoly) Then Local $r = MsgBox(BitOR($MB_ICONQUESTION, $MB_YESNO), "Question", "File already exists - overwwrite?", 5) If $r <> $IDYES Then Return MsgBox($MB_ICONINFORMATION, "Information", "Save aborted!", 15, $hGUI) EndIf EndIf If ((UBound($aFrames_LowPoly) > 1 And $bIsGIF) ? _ _GDIPlus_GIFAnimCreateFile2($aFrames_LowPoly, $sFileLowPoly, $aFrameDelays) _ : _ ($hImage_OrginalSize ? _GDIPlus_ImageSaveToFile($hImage_OrginalSize, $sFileLowPoly) _ : _ScreenCapture_SaveImage($sFileLowPoly, $hGDI_LowPoly, False))) Then MsgBox($MB_ICONINFORMATION, "Information", "Low-Poly image saved.", 15, $hGUI) Else MsgBox($MB_ICONERROR, "Error", "Low-Poly image could not be save!", 15, $hGUI) EndIf EndFunc ;==>SaveImage Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local $iNotifyCode = BitShift($wParam, 16) Local $iCtrlID = BitAND($wParam, 0x0000FFFF) Local $var If $iNotifyCode = $EN_KILLFOCUS Then Switch $iCtrlID Case $iInp_Blur $val = GUICtrlRead($iInp_Blur) If $val = "" Then $val = 5 $val = Number($val) If $val < 0 Then $val = 0 If $val > 127 Then $val = 127 GUICtrlSetData($iInp_Blur, $val) Case $iInp_Threshold $val = GUICtrlRead($iInp_Threshold) If $val = "" Then $val = 0.35 $val = Number($val) If $val < 0 Then $val = 0 If $val > 10 Then $val = 10 GUICtrlSetData($iInp_Threshold, StringFormat("%.2f", $val)) Case $iInp_Colors $val = GUICtrlRead($iInp_Colors) If $val = "" Then $val = 32 $val = Number($val) If $val < 2 Then $val = 2 If $val > 255 Then $val = 255 GUICtrlSetData($iInp_Colors, $val) Case $iInp_MinSpace $val = GUICtrlRead($iInp_MinSpace) If $val = "" Then $val = 1 $val = Number($val) If $val < 1 Then $val = 1 GUICtrlSetData($iInp_MinSpace, $val) Case $iInp_MaxSpace $val = GUICtrlRead($iInp_MaxSpace) If $val = "" Then $val = 8 $val = Number($val) If $val < 1 Then $val = 2 GUICtrlSetData($iInp_MaxSpace, $val) Case $iInp_BorderSpaceX, $iInp_BorderSpaceY $val = GUICtrlRead($iCtrlID) If $val = "" Then $val = 2 $val = Number($val) If $val < 1 Then $val = 1 If $val > 4096 Then $val = 4096 GUICtrlSetData($iCtrlID, $val) Case $iInp_Alpha $val = GUICtrlRead($iInp_Alpha) If $val = "" Then $val = 32 $val = Number($val) If $val < 0 Then $val = 0 If $val > 255 Then $val = 255 GUICtrlSetData($iInp_Alpha, $val) Case $iInp_PosterizeLvl $val = GUICtrlRead($iInp_PosterizeLvl) If $val = "" Then $val = 8 $val = Number($val) If $val < 0 Then $val = 0 If $val > 255 Then $val = 255 GUICtrlSetData($iInp_PosterizeLvl, $val) Case $iInp_DenoiseLvl $val = GUICtrlRead($iInp_DenoiseLvl) If $val = "" Then $val = 0 $val = Number($val) If $val < 0 Then $val = 0 If $val > 255 Then $val = 255 GUICtrlSetData($iInp_DenoiseLvl, $val) Case $iInp_EdgePoints $val = GUICtrlRead($iInp_EdgePoints) If $val = "" Then $val = 30 $val = Number($val) If $val < 0 Then $val = 0 If $val > 255 Then $val = 255 GUICtrlSetData($iInp_EdgePoints, $val) Case $iInp_CartoonRadius $val = GUICtrlRead($iInp_CartoonRadius) If $val = "" Then $val = 8 $val = Number($val) If $val < 0 Then $val = 0 If $val > 255 Then $val = 255 GUICtrlSetData($iInp_CartoonRadius, $val) Case $iInp_CartoonIntens $val = GUICtrlRead($iInp_CartoonIntens) If $val = "" Then $val = 20 $val = Number($val) If $val < 0 Then $val = 0 If $val > 255 Then $val = 255 GUICtrlSetData($iInp_CartoonIntens, StringFormat("%.2f", $val)) EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMAND Func _WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam) Local $i = 1 Local $aFileList = _WinAPI_DragQueryFileEx($wParam) Do If StringInStr(FileGetAttrib($aFileList[$i]), "D") Then _ArrayDelete($aFileList, $i) Else $i += 1 EndIf Until $i = UBound($aFileList) $aFileList[0] = UBound($aFileList) - 1 $sImgFile = $aFileList[1] _WinAPI_DragFinish($wParam) GUICtrlSendToDummy($iDummy_Load) Return 0 EndFunc ;==>WM_DROPFILES# Func _GDIPlus_BitmapCreateVerticalText($sString, $fFontSize = 10, $sFont = "Arial", $iColor_Text = 0xFF000000, $iTxtBorderColor = 0x80808080, $iTxtBorderSize = 1, $iFlip = 3) $iFlip = ($iFlip <> 3 And $iFlip <> 1) ? 3 : $iFlip Local Const $hDC = _WinAPI_GetWindowDC(0) Local Const $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hDC) Local Const $hBrush = _GDIPlus_BrushCreateSolid($iColor_Text), $hPen = _GDIPlus_PenCreate($iTxtBorderColor, $iTxtBorderSize) Local Const $hFormat = _GDIPlus_StringFormatCreate() Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local Const $hFont = _GDIPlus_FontCreate($hFamily, $fFontSize) Local Const $hPath = _GDIPlus_PathCreate() Local $tLayout = _GDIPlus_RectFCreate() Local $iError = 1 Local Const $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat) If Not @error Then Local Const $iW = Ceiling($aInfo[0].Width), $iH = Ceiling($aInfo[0].Height) Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH), $hCanvas = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hCanvas, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetTextRenderingHint($hCanvas, $GDIP_TEXTRENDERINGHINTANTIALIASGRIDFIT) $tLayout.X = 0 $tLayout.Y = 0 $tLayout.Width = $iW $tLayout.Height = $iH _GDIPlus_PathAddString($hPath, $sString, $tLayout, $hFamily, 0, $fFontSize, $hFormat) ;~ _GDIPlus_GraphicsDrawStringEx($hCanvas, $sString, $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_GraphicsFillPath($hCanvas, $hPath, $hBrush) _GDIPlus_GraphicsDrawPath($hCanvas, $hPath, $hPen) _GDIPlus_ImageRotateFlip($hBitmap, $iFlip) Local Const $hBitmap_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_GraphicsDispose($hCanvas) _GDIPlus_BitmapDispose($hBitmap) $iError = 0 EndIf _GDIPlus_PathDispose($hPath) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphic) _WinAPI_ReleaseDC(0, $hDC) If $iError Then Return SetError(1, 0, 0) Local $aResult[3] = [$hBitmap_GDI, $iH, $iW] Return $aResult EndFunc ;==>_GDIPlus_BitmapCreateVerticalText Func CheckVer($sVerInstalled, $sVerRequired) Local $aInst = StringSplit($sVerInstalled, ".") Local $aReq = StringSplit($sVerRequired, ".") Local $iInst, $iReq For $i = 1 To $aReq[0] $iInst = ($i <= $aInst[0]) ? Int($aInst[$i]) : 0 $iReq = Int($aReq[$i]) If $iInst > $iReq Then Return True If $iInst < $iReq Then Return False Next Return True EndFunc ;==>CheckVer #Region GIF ;_GDIPlus_GIFAnim* function taken from _GDIPlus_GIFAnim UDF Func _GDIPlus_GIFAnimGetFrameDimensionsCount($hImage) Local Const $aResult = DllCall($__g_hGDIPDll, "int", "GdipImageGetFrameDimensionsCount", "handle", $hImage, "ulong*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc ;==>_GDIPlus_GIFAnimGetFrameDimensionsCount Func _GDIPlus_GIFAnimGetFrameDimensionsList($hImage, $iFramesCount) Local Const $tGUID = DllStructCreate($tagGUID) Local Const $aResult = DllCall($__g_hGDIPDll, "int", "GdipImageGetFrameDimensionsList", "handle", $hImage, "struct*", $tGUID, "uint", $iFramesCount) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $tGUID EndFunc ;==>_GDIPlus_GIFAnimGetFrameDimensionsList Func _GDIPlus_GIFAnimGetFrameCount($hImage, $tGUID) Local Const $aResult = DllCall($__g_hGDIPDll, "int", "GdipImageGetFrameCount", "handle", $hImage, "struct*", $tGUID, "ptr*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return Int($aResult[3]) EndFunc ;==>_GDIPlus_GIFAnimGetFrameCount Func _GDIPlus_GIFAnimSelectActiveFrame($hImage, $tGUID, $iCurrentFrame) Local Const $aResult = DllCall($__g_hGDIPDll, "int", "GdipImageSelectActiveFrame", "handle", $hImage, "struct*", $tGUID, "uint", $iCurrentFrame) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return True EndFunc ;==>_GDIPlus_GIFAnimSelectActiveFrame Func _GDIPlus_GIFAnimGetFrameDelays($hImage, $iAnimFrameCount) If $iAnimFrameCount < 2 Then Return SetError(1, 0, 0) Local Const $GDIP_PROPERTYTAGFRAMEDELAY = 0x5100 Local $tPropItem = __GDIPlus_ImageGetPropertyItem($hImage, $GDIP_PROPERTYTAGFRAMEDELAY) If IsDllStruct($tPropItem) And (Not @error) Then Local $iType = $tPropItem.type, $iLength, $tVal If $iType Then $iLength = $tPropItem.length Switch $iType Case 1 $tVal = DllStructCreate("byte delay[" & $iLength & "]", $tPropItem.value) Case 3 $tVal = DllStructCreate("short delay[" & Ceiling($iLength / 2) & "]", $tPropItem.value) Case 4 $tVal = DllStructCreate("long delay[" & Ceiling($iLength / 4) & "]", $tPropItem.value) Case Else Return SetError(3, 0, 0) EndSwitch Local $aFrameDelays[Int($iAnimFrameCount)], $i For $i = 0 To UBound($aFrameDelays) - 1 $aFrameDelays[$i] = $tVal.delay(($i + 1)) * 10 Next EndIf Return $aFrameDelays EndIf Return SetError(2, 0, 0) EndFunc ;==>_GDIPlus_GIFAnimGetFrameDelays Func __GDIPlus_ImageGetPropertyItem($hImage, $iPropID) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPropertyItemSize", "handle", $hImage, "uint", $iPropID, "ulong*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Local Static $tBuffer $tBuffer = DllStructCreate("byte[" & $aResult[3] & "]") $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPropertyItem", "handle", $hImage, "uint", $iPropID, "ulong", $aResult[3], "struct*", $tBuffer) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(11, $aResult[0], 0) Local Const $tagGDIPPROPERTYITEM = "uint id;ulong length;word type;ptr value" Local $tPropertyItem = DllStructCreate($tagGDIPPROPERTYITEM, DllStructGetPtr($tBuffer)) If @error Then Return SetError(20, $aResult[0], 0) Return $tPropertyItem EndFunc ;==>__GDIPlus_ImageGetPropertyItem Func _GDIPlus_GIFAnimCreateFile2($aImages, $sFilename, $aDelays = 100, $bReplay = True) Local Const $GDIP_EVTFrameDimensionTime = 21 Local $iMax = $aImages[0] If $iMax < 1 Then Return SetError(1, 0, False) Local Const $sCLSID = _GDIPlus_EncodersGetCLSID("GIF") Local $tMultiFrameParam = DllStructCreate("int type;") $tMultiFrameParam.type = 18 Local $tParams = _GDIPlus_ParamInit(1) _GDIPlus_ParamAdd($tParams, $GDIP_EPGSAVEFLAG, 1, 4, DllStructGetPtr($tMultiFrameParam)) Local Const $hStream = _WinAPI_CreateStreamOnHGlobal() Local $tGUID = _WinAPI_GUIDFromString($sCLSID) _GDIPlus_ImageSaveToStream($aImages[1], $hStream, DllStructGetPtr($tGUID), DllStructGetPtr($tParams)) If $iMax > 1 Then $tMultiFrameParam.type = $GDIP_EVTFrameDimensionTime $tParams = _GDIPlus_ParamInit(1) _GDIPlus_ParamAdd($tParams, $GDIP_EPGSAVEFLAG, 1, 4, DllStructGetPtr($tMultiFrameParam)) For $i = 2 To $iMax _GDIPlus_ImageSaveAddImage($aImages[1], $aImages[$i], $tParams) Next $tMultiFrameParam.type = 19 $tParams = _GDIPlus_ParamInit(1) _GDIPlus_ParamAdd($tParams, $GDIP_EPGSAVEFLAG, 1, 4, DllStructGetPtr($tMultiFrameParam)) _GDIPlus_ImageSaveAdd($aImages[1], $tParams) EndIf $tMultiFrameParam.type = 20 $tParams = _GDIPlus_ParamInit(1) _GDIPlus_ParamAdd($tParams, $GDIP_EPGSAVEFLAG, 1, 4, DllStructGetPtr($tMultiFrameParam)) _GDIPlus_ImageSaveAdd($aImages[1], $tParams) Local Const $hMemory = _WinAPI_GetHGlobalFromStream($hStream) Local Const $iMemSize = _MemGlobalSize($hMemory) Local Const $pMem = _MemGlobalLock($hMemory) Local Const $iNewSize = $bReplay ? ($iMemSize + 19) : $iMemSize Local Const $hNewMem = _MemGlobalAlloc($iNewSize, 0x0002) Local Const $pNewMem = _MemGlobalLock($hNewMem) Local $tNewData = DllStructCreate("byte mem[" & $iNewSize & "]", $pNewMem) Local Const $hDLL_msvcrt = DllOpen("msvcrt.dll") Local $iCopyOffset = 0 If $bReplay Then Local $tNetscape = DllStructCreate("byte mem[19]") $tNetscape.mem = Binary("0x21FF0B4E45545343415045322E300301000000") Local $aResult = DllCall($hDLL_msvcrt, "ptr:cdecl", "memchr", "ptr", $pMem, "int", 0x21, "ulong_ptr", $iMemSize) If @error Or Not IsArray($aResult) Then _MemGlobalUnlock($hMemory) _MemGlobalUnlock($hNewMem) _MemGlobalFree($hNewMem) _WinAPI_ReleaseStream($hStream) DllClose($hDLL_msvcrt) Return SetError(3, 0, False) EndIf Local $pFound = $aResult[0], $tCheck, $iInsertPos While $pFound <> 0 $tCheck = DllStructCreate("byte mem[3]", $pFound) If $tCheck.mem(1) = 0x21 And $tCheck.mem(2) = 0xF9 And $tCheck.mem(3) = 0x04 Then $iInsertPos = $pFound - $pMem DllCall($hDLL_msvcrt, "ptr:cdecl", "memcpy", "ptr", $pNewMem, "ptr", $pMem, "ulong_ptr", $iInsertPos) DllCall($hDLL_msvcrt, "ptr:cdecl", "memcpy", "ptr", $pNewMem + $iInsertPos, "struct*", $tNetscape, "ulong_ptr", 19) DllCall($hDLL_msvcrt, "ptr:cdecl", "memcpy", "ptr", $pNewMem + $iInsertPos + 19, "ptr", $pMem + $iInsertPos, "ulong_ptr", $iMemSize - $iInsertPos) $iCopyOffset = 19 ExitLoop EndIf $aResult = DllCall($hDLL_msvcrt, "ptr:cdecl", "memchr", "ptr", $pFound + 1, "int", 0x21, "ulong_ptr", $iMemSize - ($pFound - $pMem) - 1) $pFound = $aResult[0] WEnd Else DllCall($hDLL_msvcrt, "ptr:cdecl", "memcpy", "ptr", $pNewMem, "ptr", $pMem, "ulong_ptr", $iMemSize) EndIf _MemGlobalUnlock($hMemory) _WinAPI_ReleaseStream($hStream) _MemGlobalFree($hMemory) Local $pSearch = $pNewMem Local $iRemainingByte = $iNewSize Local $iFrameCount = 0, $iDelay, $aResult, $pFound, $tCheck, $isArray = IsArray($aDelays) While $iFrameCount < $iMax And $iRemainingByte > 6 $aResult = DllCall($hDLL_msvcrt, "ptr:cdecl", "memchr", "ptr", $pSearch, "int", 0x21, "ulong_ptr", $iRemainingByte) If $aResult[0] = 0 Then ExitLoop $pFound = $aResult[0] $tCheck = DllStructCreate("byte mem[6]", $pFound) If $tCheck.mem(2) = 0xF9 And $tCheck.mem(3) = 0x04 Then $iDelay = $isArray ? $aDelays[$iFrameCount] : $aDelays $iDelay = Int($iDelay / 10) $tCheck.mem(5) = BitAND($iDelay, 0xFF) $tCheck.mem(6) = BitShift($iDelay, 8) $iFrameCount += 1 $pSearch = $pFound + 8 Else $pSearch = $pFound + 1 EndIf $iRemainingByte = $iNewSize - ($pSearch - $pNewMem) WEnd DllClose($hDLL_msvcrt) Local $hFile = FileOpen($sFilename, BitOR(16, 2)) If $hFile = -1 Then _MemGlobalUnlock($hNewMem) _MemGlobalFree($hNewMem) Return SetError(2, 0, False) EndIf FileWrite($hFile, $tNewData.mem) FileClose($hFile) _MemGlobalUnlock($hNewMem) _MemGlobalFree($hNewMem) Return True EndFunc ;==>_GDIPlus_GIFAnimCreateFile2 Func _GDIPlus_BitmapConvertTo8Bit(ByRef $hBitmap, $iColorCount = 256, $iDitherType = 9, $iPaletteType = 8, $bUseTransparentColor = True) $iColorCount = ($iColorCount > 2 ^ 8) ? 2 ^ 8 : $iColorCount Local $tPalette = _GDIPlus_PaletteInitialize(256, $iPaletteType, $iColorCount, $bUseTransparentColor, $hBitmap) If @error Then Return SetError(1, @error, 0) Local $iRet = _GDIPlus_BitmapConvertFormat($hBitmap, 0x00030803, $iDitherType, $iPaletteType, $tPalette) If @error Then Return SetError(2, @error, 0) Return $iRet EndFunc ;==>_GDIPlus_BitmapConvertTo8Bit #EndRegion GIF Examples: The required DLLs (_GDIPlus_BitmapApplyFilter.dll / _GDIPlus_BitmapApplyFilter_x64.dll) and _GDIPlus_BitmapApplyFilter.au3 can be found on my OneDrive: _GDIPlus_BitmapApplyFilter
  2. Hi there. Abstract This UDF enables the use of all reference APL features in AutoIt. Is uses the original APL symbols. The code is interpreted via a sandbox ngn-apl interface which relies on JavaScript. Execution is done via IE objects. What's APL? APL is a formal, imperative language. Because it is imperative, a sentence may be called an instruction, and may be executed to produce a result. StringAPL() has one main parameter, which is the APL source code. Thus: StringAPL("2×(3+4)") = "14"Unlike traditionally structured programming languages, code in APL is typically structured as chains of monadic or dyadic functions and operators acting on arrays. As APL has many nonstandard primitives (functions and operators, indicated by a single symbol or a combination of a few symbols), it does not have function or operator precedence. The APL environment is called a workspace. In a workspace the user can define programs and data, i.e. the data values exist also outside the programs, and the user can manipulate the data without the necessity to define a program. For example, StringAPL("N ← 4 5 6 7")will initialize a vector "N" containing 4 elements according to the command. After each StringAPL call, the workspace is deleted completely, so you have to use multi-instructions if you want to reuse macros, functions or variables. Now that we have "N" we can manipulate it. Here's just a small example, you can do much more with APL (later more): N+4Will perform an addition. Every element in N is increased by (int)4. Easy, at least for now ;-) What's possible? Everything. If you feel like it, just draw a mandelbrot fractal using only one line 'o code. Or solve the n-Queen problem, or determine the first hundred prime numbers, or parse a html file. APL is like RegEx on crack. Some really advanced examples are included within the example file. Now, why isn't APL more popular? Because it uses a very, very strange charset. In fact, you have to install the APL Unicode font (https://sites.google.com/site/baavector/fonts) and set SciTe to use this font (CTRL+1 -> Change Monospace Font), before you can even view the examples! In addition to that, you scripts have to be UTF8 BOM encoded, which in return causes Au3Check to crash whenever custom includes are used. I'm planning on replacing the APL chrs with hum-readable english commands, but that may take some time :-) Just look at the mandelbrot drawing code, it's absolutely ridiculous!: I'd call it abstract art . Examples There are a few examples included. For the basic stuff please visit the Wikipedia APL page und Wikipedia APL reference: Remarks Please do not use the second parameter yet, it is unfinished and experimental. Also, to use multiline-code, use . in-command to start a new line, just like the examples. Download Example file (INSTALL APL FONT AND ENCODE UTF8BOM!!!) UDF (doesn't need any special treatment, doesn't contain APL chrs) https://github.com/Perseus-Developers/StringAPL Does not work in 3.3.9.5. Developed in 3.3.8.1. No further testing, please report bugs only if they occur in a stable version.
×
×
  • Create New...