-
Posts
7,300 -
Joined
-
Last visited
-
Days Won
76
UEZ last won the day on April 7 2024
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
-
spudw2k reacted to a post in a topic: How to create rounded corners? (_GDIPlus)
-
robertocm reacted to a post in a topic: How to create rounded corners? (_GDIPlus)
-
SEKOMD reacted to a post in a topic: Please help improve the function (_GDIPlus, draw text)
-
Please help improve the function (_GDIPlus, draw text)
UEZ replied to SEKOMD's topic in AutoIt General Help and Support
You may try something like this here: ;Coded by UEZ #include <Constants.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global Const $STM_SETIMAGE = 0x0172 _GDIPlus_Startup() Global $iW = 600, $iH = 400, $sText = @MSEC, $bHover = False, $iTimer = 30 Global $iBGColor = 0xFF808080, $iBtnBGColor = 0xFF1BA0E1 Global $hGUI = GUICreate("Test", $iW, $iH, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_THICKFRAME)) Global $idPic = GUICtrlCreatePic("", $iW / 4, $iH / 4, $iW / 2, $iH / 2) GUICtrlSetResizing(-1, $GUI_DOCKVCENTER + $GUI_DOCKHCENTER) GUISetBkColor(BitAND($iBGColor, 0xFFFFFF), $hGUI) Global $aSize = ControlGetPos($hGUI, "", $idPic) Global $aHBitmap = _GDIPlus_BitmapCreateRoundedButtonAndText($sText, $iW / 2, $iH / 2, $iBtnBGColor, $aSize[2] / 4, $iBGColor) Global $hB = GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $aHBitmap[0]) If $hB Then _WinAPI_DeleteObject($hB) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO") GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUIRegisterMsg($WM_TIMER, "Animate") Global $iID = DllCall("user32.dll", "uint_ptr", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iTimer, "int", 0)[0] While 1 If WinActive($hGUI) Then $aMouseInfo = GUIGetCursorInfo($hGUI) ;hover simulation Switch $aMouseInfo[4] Case $idPic $bHover = True Case Else $bHover = False EndSwitch EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE DllCall("user32.dll", "bool", "KillTimer", "hwnd", $hGUI, "uint_ptr", $iID) GUIRegisterMsg($WM_TIMER, "") GUIRegisterMsg($WM_SIZE, "") GUIRegisterMsg($WM_GETMINMAXINFO, "") _GDIPlus_Shutdown() GUIDelete() Exit Case $idPic GUIRegisterMsg($WM_TIMER, "") MsgBox($MB_TOPMOST, "Information", "Button pressed") GUIRegisterMsg($WM_TIMER, "Animate") EndSwitch WEnd Func Animate() $sText = @MSEC WM_SIZE($hGUI, 0, 0, 0) EndFunc Func WM_SIZE($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $aSize = ControlGetPos($hWnd, "", $idPic) Local $aHBitmap = _GDIPlus_BitmapCreateRoundedButtonAndText($sText, $aSize[2], $aSize[3], $iBtnBGColor, $aSize[2] / 4, $iBGColor) Local $hB = GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $bHover ? $aHBitmap[1] : $aHBitmap[0]) If $hB Then _WinAPI_DeleteObject($hB) _WinAPI_DeleteObject($aHBitmap[0]) _WinAPI_DeleteObject($aHBitmap[1]) Return "GUI_RUNDEFMSG" EndFunc Func WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam) Local $minmaxinfo = DllStructCreate("long ptReserved;long ptReserved;long ptMaxSizeX;long ptMaxSizeY;long ptMaxPositionX;long ptMaxPositionY;long ptMinTrackSizeX;long ptMinTrackSizeY;long ptMaxTrackSizeX;long ptMaxTrackSizeY", $lParam) With $minmaxinfo .ptMinTrackSizeX = 200 .ptMinTrackSizeY = 100 .ptMaxTrackSizeX = @DesktopWidth * 0.8 .ptMaxTrackSizeY = @DesktopHeight * 0.8 EndWith Return "GUI_RUNDEFMSG" EndFunc ;==>WM_GETMINMAXINFO ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GDIPlus_BitmapCreateRoundedButtonAndText ; Description ...: Draw rounded button ; Syntax ........: _GDIPlus_BitmapCreateRoundedButtonAndText($sString, $iWidth, $iHeight[, $iBgColor = 0xFF1BA0E1[, $iFontSize = 16[, $sFont = "Times New Roman"[, ; $iHoverColor = 0xFFC9388C[, $iFrameSize = 2[, $iFontFrameColor = 0x408AD5EA[, $iFontColor = 0xFFFFFFFF]]]]]]) ; Parameters ....: $sString - A string value. ; $iWidth - An integer value. ; $iHeight - An integer value. ; $iBgColor - [optional] An integer value. Default is 0xFF1BA0E1. ; $iFontSize - [optional] An integer value. Default is 16. ; $sFont - [optional] A string value. Default is "Times New Roman". ; $iBGGfx - [optional] An integer value. Default is 0xFFF0F0F0 ; $iHoverColor - [optional] An integer value. Default is 0xFFFFFFFF. ; $iFrameSize - [optional] An integer value. Default is 2. ; $iFontFrameColor - [optional] An integer value. Default is 0x408AD5EA. ; $iFontColor - [optional] An integer value. Default is 0xFFFFFFFF. ; Return values .: an array with 2 GDI bitmap handles -> [0]: default button, [1]: hover button ; Author ........: UEZ ; Version .......: 0.85 build 2025-01-14 ; Modified ......: ; Remarks .......: Dispose returned GDI bitmap handles when done ; Example .......: Yes ; =============================================================================================================================== Func _GDIPlus_BitmapCreateRoundedButtonAndText($sString, $iWidth, $iHeight, $iBgColor = 0xFF1BA0E1, $iFontSize = 16, $iBGGfx = 0xFFF0F0F0, $sFont = "Times New Roman", $iHoverColor = 0xFFFFFFFF, $iFrameSize = 2, $iFontFrameColor = 0x408AD5EA, $iFontColor = 0xFFFFFFFF) ;some checks If $sString = "" Then Return SetError(1, 0, 0) If Int($iWidth) < $iFrameSize * 2 Then Return SetError(2, 0, 0) If Int($iHeight) < $iFrameSize * 2 Then Return SetError(3, 0, 0) ;create font objects Local Const $hFormat = _GDIPlus_StringFormatCreate() Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local $tLayout = _GDIPlus_RectFCreate(0, 0, $iWidth, $iHeight) _GDIPlus_StringFormatSetAlign($hFormat, 1) ;center string on X axis _GDIPlus_StringFormatSetLineAlign($hFormat, 1) ;center string on Y axis ;create bitmap and graphics context handles Local Const $aBitmaps[2] = [_GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight), _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)] Local Const $aGfxCtxt[2] = [_GDIPlus_ImageGetGraphicsContext($aBitmaps[0]), _GDIPlus_ImageGetGraphicsContext($aBitmaps[1])] _GDIPlus_GraphicsClear($aGfxCtxt[0], $iBGGfx) _GDIPlus_GraphicsClear($aGfxCtxt[1], $iBGGfx) ;set drawing quality _GDIPlus_GraphicsSetSmoothingMode($aGfxCtxt[0], $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetSmoothingMode($aGfxCtxt[1], $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetTextRenderingHint($aGfxCtxt[0], $GDIP_TEXTRENDERINGHINTANTIALIASGRIDFIT) ;define brush and pen objects Local Const $hBrushFontColor = _GDIPlus_BrushCreateSolid($iFontColor) Local Const $hPenFontFrameColor = _GDIPlus_PenCreate($iFontFrameColor, $iFrameSize), $hPenHoverColor = _GDIPlus_PenCreate($iHoverColor, $iFrameSize) ;create path object Local Const $hPath = _GDIPlus_PathCreate() ;create cloned path object for string measurement Local Const $hPath_Dummy = _GDIPlus_PathClone($hPath) _GDIPlus_PathAddString($hPath_Dummy, $sString, $tLayout, $hFamily, 0, $iFontSize, $hFormat) ;create rounded borders Local $fArcSize = $iWidth * 0.2 _GDIPlus_PathStartFigure($hPath) _GDIPlus_PathAddArc($hPath, $iFrameSize, $iHeight - $fArcSize - $iFrameSize, $fArcSize, $fArcSize, 180, -90) ;BR _GDIPlus_PathAddArc($hPath, $iWidth - $fArcSize - $iFrameSize, $iHeight - $fArcSize - $iFrameSize, $fArcSize, $fArcSize, -270, -90) ;BL _GDIPlus_PathAddArc($hPath, $iWidth - $fArcSize - $iFrameSize, $iFrameSize, $fArcSize, $fArcSize, 0, -90) ;TR _GDIPlus_PathAddArc($hPath, $iFrameSize, $iFrameSize, $fArcSize, $fArcSize, -90, -90) ;TL _GDIPlus_PathCloseFigure($hPath) Local Const $hPath_Clone = _GDIPlus_PathClone($hPath) ;needed to fill button background and border paint Local Const $hBrushBGColor = _GDIPlus_PathBrushCreateFromPath($hPath) _GDIPlus_PathBrushSetSurroundColor($hBrushBGColor, $iBgColor) _GDIPlus_PathBrushSetCenterColor($hBrushBGColor, 0xFFFFFFFF) _GDIPlus_PathBrushSetCenterPoint($hBrushBGColor, $iWidth / 2, $iHeight / 2) _GDIPlus_PathBrushSetSigmaBlend($hBrushBGColor, 1, 0.33333) _GDIPlus_GraphicsFillPath($aGfxCtxt[0], $hPath, $hBrushBGColor) _GDIPlus_GraphicsDrawPath($aGfxCtxt[0], $hPath, $hPenFontFrameColor) _GDIPlus_PathReset($hPath) ;add string to path _GDIPlus_PathAddString($hPath, $sString, $tLayout, $hFamily, 1, $iFontSize, $hFormat) ;clear bitmap and draw string _GDIPlus_GraphicsFillPath($aGfxCtxt[0], $hPath, $hBrushFontColor) _GDIPlus_GraphicsDrawPath($aGfxCtxt[0], $hPath, $hPenFontFrameColor) ;draw rectangle on cloned bitmap for hover effect _GDIPlus_GraphicsDrawImageRect($aGfxCtxt[1], $aBitmaps[0], 0, 0, $iWidth, $iHeight) _GDIPlus_GraphicsDrawPath($aGfxCtxt[1], $hPath_Clone, $hPenHoverColor) ;dispose object resources _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_PathDispose($hPath) _GDIPlus_PathDispose($hPath_Dummy) _GDIPlus_PathDispose($hPath_Clone) _GDIPlus_GraphicsDispose($aGfxCtxt[0]) _GDIPlus_GraphicsDispose($aGfxCtxt[1]) _GDIPlus_BrushDispose($hBrushFontColor) _GDIPlus_BrushDispose($hBrushBGColor) _GDIPlus_PenDispose($hPenFontFrameColor) _GDIPlus_PenDispose($hPenHoverColor) ;create GDI bitmap for later usage Local $aHBitmaps[2] = [_GDIPlus_BitmapCreateHBITMAPFromBitmap($aBitmaps[0]), _GDIPlus_BitmapCreateHBITMAPFromBitmap($aBitmaps[1])] ;dispose GDI+ bitmaps _GDIPlus_BitmapDispose($aBitmaps[0]) _GDIPlus_BitmapDispose($aBitmaps[1]) Return $aHBitmaps EndFunc ;==>_GDIPlus_BitmapCreateRoundedButtonAndText -
SEKOMD reacted to a post in a topic: How to create rounded corners? (_GDIPlus)
-
Danyfirex reacted to a post in a topic: How to create rounded corners? (_GDIPlus)
-
ioa747 reacted to a post in a topic: How to create rounded corners? (_GDIPlus)
-
How to create rounded corners? (_GDIPlus)
UEZ replied to SEKOMD's topic in AutoIt General Help and Support
I modified one of my old script from 2014: ;Coded by UEZ #include <GUIConstantsEx.au3> #include <GDIPlus.au3> _GDIPlus_Startup() Global Const $STM_SETIMAGE = 0x0172 Global Const $hGUI = GUICreate("GDI+ Test", 200, 100) GUISetBkColor(0x505050) Global Const $iPicBtn = GUICtrlCreatePic("", 50, 28, 100, 44) Global $aButtons = _GDIPlus_BitmapCreateRoundedButtonAndText("install", 100, 44) _WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[0])) GUISetState() Global $aMouseInfo, $bShow = False, $bHide = False Do If WinActive($hGUI) Then $aMouseInfo = GUIGetCursorInfo($hGUI) ;hover simulation Switch $aMouseInfo[4] Case $iPicBtn _WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[1])) $bShow = True $bHide = False Case Else _WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[0])) $bHide = True $bShow = False EndSwitch EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($aButtons[0]) _WinAPI_DeleteObject($aButtons[1]) _GDIPlus_Shutdown() Exit Case $iPicBtn MsgBox(0, "Information", "Button pressed") EndSwitch Until False ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GDIPlus_BitmapCreateRoundedButtonAndText ; Description ...: Draw rounded button ; Syntax ........: _GDIPlus_BitmapCreateRoundedButtonAndText($sString, $iWidth, $iHeight[, $iBgColor = 0xFF1BA0E1[, $iFontSize = 16[, $sFont = "Times New Roman"[, ; $iHoverColor = 0xFFC9388C[, $iFrameSize = 2[, $iFontFrameColor = 0x408AD5EA[, $iFontColor = 0xFFFFFFFF]]]]]]) ; Parameters ....: $sString - A string value. ; $iWidth - An integer value. ; $iHeight - An integer value. ; $iBgColor - [optional] An integer value. Default is 0xFF1BA0E1. ; $iFontSize - [optional] An integer value. Default is 16. ; $sFont - [optional] A string value. Default is "Times New Roman". ; $iHoverColor - [optional] An integer value. Default is 0xFFC9388C. ; $iFrameSize - [optional] An integer value. Default is 2. ; $iFontFrameColor - [optional] An integer value. Default is 0x408AD5EA. ; $iFontColor - [optional] An integer value. Default is 0xFFFFFFFF. ; Return values .: an array with 2 GDI bitmap handles -> [0]: default button, [1]: hover button ; Author ........: UEZ ; Version .......: 0.85 build 2025-01-12 ; Modified ......: ; Remarks .......: Dispose returned GDI bitmap handles when done ; Example .......: Yes ; =============================================================================================================================== Func _GDIPlus_BitmapCreateRoundedButtonAndText($sString, $iWidth, $iHeight, $iBgColor = 0xFF1BA0E1, $iFontSize = 16, $sFont = "Times New Roman", $iHoverColor = 0xF0FFFFFF, $iFrameSize = 2, $iFontFrameColor = 0x408AD5EA, $iFontColor = 0xFFFFFFFF) ;some checks If $sString = "" Then Return SetError(1, 0, 0) If Int($iWidth) < $iFrameSize * 2 Then Return SetError(2, 0, 0) If Int($iHeight) < $iFrameSize * 2 Then Return SetError(3, 0, 0) ;create font objects Local Const $hFormat = _GDIPlus_StringFormatCreate() Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local $tLayout = _GDIPlus_RectFCreate(0, 0, $iWidth, $iHeight) _GDIPlus_StringFormatSetAlign($hFormat, 1) ;center string on X axis _GDIPlus_StringFormatSetLineAlign($hFormat, 1) ;center string on Y axis ;create bitmap and graphics context handles Local Const $aBitmaps[2] = [_GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight), _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)] Local Const $aGfxCtxt[2] = [_GDIPlus_ImageGetGraphicsContext($aBitmaps[0]), _GDIPlus_ImageGetGraphicsContext($aBitmaps[1])] ;set drawing quality _GDIPlus_GraphicsSetSmoothingMode($aGfxCtxt[0], $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetSmoothingMode($aGfxCtxt[1], $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetTextRenderingHint($aGfxCtxt[0], $GDIP_TEXTRENDERINGHINTANTIALIASGRIDFIT) ;define brush and pen objects Local Const $hBrushFontColor = _GDIPlus_BrushCreateSolid($iFontColor) ;, $hBrushBGColor = _GDIPlus_BrushCreateSolid($iBgColor) Local Const $hPenFontFrameColor = _GDIPlus_PenCreate($iFontFrameColor, $iFrameSize), $hPenHoverColor = _GDIPlus_PenCreate($iHoverColor, $iFrameSize) ;create path object Local Const $hPath = _GDIPlus_PathCreate() ;create cloned path object for string measurement Local Const $hPath_Dummy = _GDIPlus_PathClone($hPath) _GDIPlus_PathAddString($hPath_Dummy, $sString, $tLayout, $hFamily, 0, $iFontSize, $hFormat) _GDIPlus_PathStartFigure($hPath) Local $fArcSize = $iWidth * 0.33333 _GDIPlus_PathAddArc($hPath, $iFrameSize, $iHeight - $fArcSize - $iFrameSize, $fArcSize, $fArcSize, 180, -90) ;BR _GDIPlus_PathAddArc($hPath, $iWidth - $fArcSize - $iFrameSize, $iHeight - $fArcSize - $iFrameSize, $fArcSize, $fArcSize, -270, -90) ;BL _GDIPlus_PathAddArc($hPath, $iWidth - $fArcSize - $iFrameSize, $iFrameSize, $fArcSize, $fArcSize, 0, -90) ;TR _GDIPlus_PathAddArc($hPath, $iFrameSize, $iFrameSize, $fArcSize, $fArcSize, -90, -90) ;TL _GDIPlus_PathCloseFigure($hPath) Local Const $hPath_Clone = _GDIPlus_PathClone($hPath) Local Const $hBrushBGColor = _GDIPlus_PathBrushCreateFromPath($hPath) _GDIPlus_PathBrushSetSurroundColor($hBrushBGColor, $iBgColor) _GDIPlus_PathBrushSetCenterColor($hBrushBGColor, 0xFFFFFFFF) _GDIPlus_PathBrushSetCenterPoint($hBrushBGColor, $iWidth / 2, $iHeight / 2) _GDIPlus_PathBrushSetSigmaBlend($hBrushBGColor, 1, 0.33333) _GDIPlus_GraphicsFillPath($aGfxCtxt[0], $hPath, $hBrushBGColor) _GDIPlus_GraphicsDrawPath($aGfxCtxt[0], $hPath, $hPenFontFrameColor) _GDIPlus_PathReset($hPath) ;add string to path _GDIPlus_PathAddString($hPath, $sString, $tLayout, $hFamily, 1, $iFontSize, $hFormat) ;clear bitmap and draw string _GDIPlus_GraphicsFillPath($aGfxCtxt[0], $hPath, $hBrushFontColor) _GDIPlus_GraphicsDrawPath($aGfxCtxt[0], $hPath, $hPenFontFrameColor) ;draw rectangle on cloned bitmap for hover effect _GDIPlus_GraphicsDrawImageRect($aGfxCtxt[1], $aBitmaps[0], 0, 0, $iWidth, $iHeight) _GDIPlus_GraphicsDrawPath($aGfxCtxt[1], $hPath_Clone, $hPenHoverColor) ;dispose object resources _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_PathDispose($hPath) _GDIPlus_PathDispose($hPath_Dummy) _GDIPlus_PathDispose($hPath_Clone) _GDIPlus_GraphicsDispose($aGfxCtxt[0]) _GDIPlus_GraphicsDispose($aGfxCtxt[1]) _GDIPlus_BrushDispose($hBrushFontColor) _GDIPlus_BrushDispose($hBrushBGColor) _GDIPlus_PenDispose($hPenFontFrameColor) _GDIPlus_PenDispose($hPenHoverColor) ;create GDI bitmap for later usage Local $aHBitmaps[2] = [_GDIPlus_BitmapCreateHBITMAPFromBitmap($aBitmaps[0]), _GDIPlus_BitmapCreateHBITMAPFromBitmap($aBitmaps[1])] ;dispose GDI+ bitmaps _GDIPlus_BitmapDispose($aBitmaps[0]) _GDIPlus_BitmapDispose($aBitmaps[1]) Return $aHBitmaps EndFunc ;==>_GDIPlus_BitmapCreateRoundedButtonAndText -
How can my UDF find dependency DLLs
UEZ replied to emcodem's topic in AutoIt General Help and Support
Sorry, then I misunderstood your problem. As far as I understand your problem, RTFC's suggestion would be the best. There are a lot of portable programs with a setup routine. -
UEZ changed their profile photo
-
How can my UDF find dependency DLLs
UEZ replied to emcodem's topic in AutoIt General Help and Support
I wrote this function to list the imports of a DLL. ;Coded by UEZ build 2024-06-09 #AutoIt3Wrapper_UseX64=n #include <Array.au3> #include <Debug.au3> #include <String.au3> #include <WinAPIFiles.au3> #include <WinAPIProc.au3> #include <WinAPIRes.au3> #include <WinAPISys.au3> Const $IMAGE_DIRECTORY_ENTRY_IMPORT = 1 Global $sFile = FileOpenDialog("Select a DLL file", "", "DLL (*.dll)", $FD_FILEMUSTEXIST) If @error Then Exit Global $a = _WinAPI_GetBinaryType2($sFile) Global $b = _WinAPI_GetBinaryType2(_WinAPI_GetProcessFileName()) If $a <> $b Or $a = "Error" Or $b = "Error" Then Exit MsgBox($MB_ICONERROR, "Error", "Script and DLL have not same binary type!", 10) Global $i, $aResult = _WinAPI_ListDLLImports($sFile) _DebugArrayDisplay($aResult, StringRegExpReplace($sFile, ".+\\(.+)", "$1") & " imports") Func _WinAPI_ListDLLImports($sFile, $iLevel = 1, $bRec = False, $bDisplayLocalFilesOnly = True, $iMaxRecLevel = 10) If $iLevel > $iMaxRecLevel Then Return Local Const $hModule = _WinAPI_LoadLibraryEx($sFile, BitOR($DONT_RESOLVE_DLL_REFERENCES, $LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR)) If Not $hModule Then Return SetError(1, 0, 0) Local Const $tSize = DllStructCreate("ulong bytes") ;https://learn.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-imagedirectoryentrytodata Local Const $aReturn = DllCall("Dbghelp.dll", "ptr", "ImageDirectoryEntryToData", "ptr", $hModule, "boolean", True, "ushort", $IMAGE_DIRECTORY_ENTRY_IMPORT, "struct*", $tSize) If Not IsArray($aReturn) Or @error Then _WinAPI_FreeLibrary($hModule) Return SetError(2, 0, 0) EndIf If Not $aReturn[0] Then _WinAPI_FreeLibrary($hModule) Return SetError(3, 0, 0) EndIf Local $tIMAGE_IMPORT_DESCRIPTOR, $sDLLName, $sPath = StringRegExpReplace($sFile, "(.+\\).+", "$1"), $sFN, $i = 0, $sDLL = StringRegExpReplace($sFile, ".+\\(.+)", "$1") Static $sDLLFiles = "" ConsoleWrite(_StringRepeat(@TAB, $iLevel - 1) & $sDLL & @CRLF) If $iLevel > 1 Then $sDLLFiles &= $sDLL & "|" While 1 $tIMAGE_IMPORT_DESCRIPTOR = DllStructCreate("dword dummy;dword TimeDateStamp;dword ForwarderChain;dword Name;dword FirstThunk;", $aReturn[0] + $i) If Not $tIMAGE_IMPORT_DESCRIPTOR.FirstThunk Then _WinAPI_FreeLibrary($hModule) If $iLevel = 1 Then Local $aResult = StringSplit(StringTrimRight($sDLLFiles, 1), "|", 2) $aResult = _ArrayUnique($aResult, 0, 0, 0, $ARRAYUNIQUE_NOCOUNT) _ArraySort($aResult) Return $aResult EndIf Return Else $sDLLName = _WinAPI_WideCharToMultiByte(DllStructCreate("char s[256];", $hModule + $tIMAGE_IMPORT_DESCRIPTOR.name).s, 65001) $sFN = $sPath & $sDLLName If $bRec Then If FileExists($sFN) Then $iLevel += 1 _WinAPI_ListDLLImports($sFN, $iLevel) $iLevel -= 1 Else If Not $bDisplayLocalFilesOnly Then $sDLLFiles &= $sDLLName & "|" ConsoleWrite($iLevel & ":" & _StringRepeat(@TAB, $iLevel) & $sDLLName & @CRLF) EndIf Else ConsoleWrite($iLevel & ":" & _StringRepeat(@TAB, $iLevel) & $sDLLName & @CRLF) If Not $bDisplayLocalFilesOnly Then $sDLLFiles &= $sDLLName & "|" Else If FileExists($sFN) Then $sDLLFiles &= $sDLLName & "|" EndIf EndIf Endif $i += DllStructGetSize($tIMAGE_IMPORT_DESCRIPTOR) WEnd EndFunc ; #FUNCTION# ==================================================================================================================== ; Author.........: UEZ ; Modified.......: ; =============================================================================================================================== Func _WinAPI_GetBinaryType2($sFile) Local $hFile = _WinAPI_CreateFile($sFile, 2, 2, 2) If Not $hFile Or @error Then Return SetError(1, 0, 0) Local $hMapping = _WinAPI_CreateFileMapping($hFile, 0, Null, $PAGE_READONLY, Null) If Not $hMapping Then _WinAPI_CloseHandle($hFile) Return SetError(2, 0, 0) EndIf Local Const $pAddress = _WinAPI_MapViewOfFile($hMapping, 0, 0, $FILE_MAP_READ) If Not $pAddress Or @error Then __ReturnGBT2($hMapping, $hFile, 3) Local Const $aHeader = DllCall("Dbghelp.dll", "ptr", "ImageNtHeader", "ptr", $pAddress) If @error Or IsArray($aHeader) = 0 Then Return __ReturnGBT2($hMapping, $hFile, 4) Local Const $tIMAGE_NT_HEADERS = DllStructCreate("dword Signature;ptr FileHeader;ptr OptionalHeader;", $aHeader[0]) If @error Or Not IsDllStruct($tIMAGE_NT_HEADERS) Then Return __ReturnGBT2($hMapping, $hFile, 5) Local Const $tIMAGE_FILE_HEADER = DllStructCreate("word Machine;word NumberOfSections;dword TimeDateStamp;dword PointerToSymbolTable;dword NumberOfSymbols;word SizeOfOptionalHeader;word Characteristics;", _ DllStructGetPtr($tIMAGE_NT_HEADERS) + 4) If @error Or Not IsDllStruct($tIMAGE_FILE_HEADER) Then Return __ReturnGBT2($hMapping, $hFile, 6) __ReturnGBT2($hMapping, $hFile, 0) Switch $tIMAGE_FILE_HEADER.Machine Case 0x014c Return "x86" Case 0x0200 Return "Intel Itanium" Case 0x8664 Return "x64" Case Else Return "Error" EndSwitch EndFunc ;==>_WinAPI_GetBinaryType2 Func __ReturnGBT2(Byref $hMapping, ByRef $hFile, $iError) _WinAPI_CloseHandle($hMapping) _WinAPI_CloseHandle($hFile) If $iError Then Return SetError($iError, 0, 0) EndFunc ;==>__ReturnGBT2 -
Parsix reacted to a post in a topic: Adobe AIR like window
-
PoneToungthar reacted to a post in a topic: WebP v0.3.1 build 2022-06-18 beta
-
You can use _GDIPlus_ImageResize() instead. You have to do some math if you want to keep aspect ratio.
-
argumentum reacted to a post in a topic: WebP v0.3.1 build 2022-06-18 beta
-
PoneToungthar reacted to a post in a topic: WebP v0.3.1 build 2022-06-18 beta
-
Try this: Example1.au3 ;Coded by UEZ #AutoIt3Wrapper_UseX64=y #include <GUIConstantsEx.au3> #include "WebP.au3" ;~ Global $sFile Global $sFile = FileOpenDialog("Select an image", "", "Images (*.webp)") If @error Then Exit Global Const $STM_SETIMAGE = 0x0172 _GDIPlus_Startup() Global Const $hImage = WebP_BitmapCreateGDIp($sFile) ;load webp image as gdiplus Global Const $hImage_Scaled = _GDIPlus_ImageScale($hImage, 0.5, 0.5) ;shrink image to 50% Global Const $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage_Scaled) ;convert gdiplus image to gdi image _GDIPlus_ImageDispose($hImage_Scaled) ;dispose gdiplus image _GDIPlus_ImageDispose($hImage) ;dispose gdiplus image ;get image dimension from gdi image Global $tDim = DllStructCreate($tagBITMAP) DllCall("gdi32.dll", "int", "GetObject", "int", $hBitmap, "int", DllStructGetSize($tDim), "ptr", DllStructGetPtr($tDim)) Global Const $iW = DllStructGetData($tDim, "bmWidth"), $iH = DllStructGetData($tDim, "bmHeight") ;display shrinked image in GUI Global Const $hGUI = GUICreate("WebP Image Viewer", $iW, $iH) GUISetBkColor(0xFFFFFF) Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW - 1, $iH - 1) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)) GUISetState() _WinAPI_DeleteObject($hBitmap) ;dispose gdi image _GDIPlus_Shutdown() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE
-
Maybe there are some dependencies missing (exports) for libpq.dll WS2_32.dll libintl-9.dll Secur32.dll WLDAP32.dll libssl-3-x64.dll libcrypto-3-x64.dll KERNEL32.dll SHELL32.dll ADVAPI32.dll VCRUNTIME140.dll api-ms-win-crt-heap-l1-1-0.dll api-ms-win-crt-convert-l1-1-0.dll api-ms-win-crt-string-l1-1-0.dll api-ms-win-crt-stdio-l1-1-0.dll api-ms-win-crt-runtime-l1-1-0.dll api-ms-win-crt-environment-l1-1-0.dll api-ms-win-crt-time-l1-1-0.dll api-ms-win-crt-utility-l1-1-0.dll api-ms-win-crt-math-l1-1-0.dll api-ms-win-crt-locale-l1-1-0.dll api-ms-win-crt-filesystem-l1-1-0.dll because DllOpen(@ScriptDir & "\libpq.dll") returns -1 which is not ok.
-
Try Local $Conn = DllCall(@ScriptDir & "\libpq.dll","int","PQlibVersion") or if cdecl calling method Local $Conn = DllCall(@ScriptDir & "\libpq.dll","int:cdecl","PQlibVersion")
-
UEZ reacted to a post in a topic: [solved] SetThumbnailTooltip
-
I misread the question but you can cut the string from CRLF #include <GUIConstantsEx.au3> $sTitle = "AutoIt v3" & @CRLF & "A BASIC-like scripting language" & @CRLF & "Blah" $sNew = StringRegExp($sTitle, "(.+)\r\n", 3) $hGUI = GUICreate(IsArray($sNew) ? $sNew[0] : $sTitle, 400, 100) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGUI)
-
Works on my Win10 22h2 Notebook properly.
-
UEZ reacted to a file: zPlayer - a small audio and video player based on winmm.dll
-
This works for me: ;Coded by UEZ build 2024-06-29 #include <WinAPIConv.au3> #AutoIt3Wrapper_UseX64=n Global Const $XM_RESOURCE = 0, $XM_MEMORY = 1, $XM_FILE = 2, $XM_NOLOOP = 8, $XM_SUSPENDED = 16, $uFMOD_MIN_VOL = 0, $uFMOD_MAX_VOL = 25, $uFMOD_DEFAULT_VOL = 25 Global $g_iDLLPath = DllOpen(@ScriptDir & "\ufmod.dll") Func uFMOD_PlaySongFile($sFilename, $param = 0, $fdwSong = $XM_FILE) Local Const $aReturn = DllCall($g_iDLLPath, "ptr", "uFMOD_PlaySong", "str", $sFilename, "ulong", $param, "ulong", $fdwSong) If @error Or Not IsArray($aReturn) Then Return SetError(1, 0, 0) If Not $aReturn[0] Then Return SetError(2, 0, 0) Return $aReturn[0] EndFunc Func uFMOD_PlaySongMem($pMem, $iSize, $fdwSong = $XM_MEMORY) Local Const $aReturn = DllCall($g_iDLLPath, "ptr", "uFMOD_PlaySong", "ptr", $pMem, "ulong", $iSize, "ulong", $fdwSong) If @error Or Not IsArray($aReturn) Then Return SetError(1, 0, 0) If Not $aReturn[0] Then Return SetError(2, 0, 0) Return $aReturn[0] EndFunc Func uFMOD_StopSong() DllCall($g_iDLLPath, "ptr", "uFMOD_PlaySong", "str", "", "long", 0, "long", 0) Return 1 EndFunc Func uFMOD_PauseSong() DllCall($g_iDLLPath, "none", "uFMOD_Pause") Return 1 EndFunc Func uFMOD_ResumeSong() DllCall($g_iDLLPath, "none", "uFMOD_Resume") Return 1 EndFunc Func uFMOD_SetVolume($iVol) DllCall($g_iDLLPath, "none", "uFMOD_SetVolume", "long", $iVol) Return 1 EndFunc Func uFMOD_GetStats() Local Const $aReturn = DllCall($g_iDLLPath, "int", "uFMOD_GetStats") If @error Or Not IsArray($aReturn) Then Return SetError(1, 0, 0) If Not $aReturn[0] Then Return SetError(2, 0, 0) Local $aRMS[] = [_WinAPI_HiWord($aReturn[0]), _WinAPI_LoWord($aReturn[0])] ;L / R channel Return $aRMS EndFunc Func uFMOD_GetRowOrder() Local Const $aReturn = DllCall($g_iDLLPath, "int", "uFMOD_GetRowOrder") If @error Or Not IsArray($aReturn) Then Return SetError(1, 0, 0) If Not $aReturn[0] Then Return SetError(2, 0, 0) Return $aReturn[0] EndFunc Func uFMOD_GetTime() Local Const $aReturn = DllCall($g_iDLLPath, "long", "uFMOD_GetTime") If @error Or Not IsArray($aReturn) Then Return SetError(1, 0, 0) If Not $aReturn[0] Then Return SetError(2, 0, 0) Return $aReturn[0] EndFunc Func uFMOD_GetTitle() Local Const $aReturn = DllCall($g_iDLLPath, "str", "uFMOD_GetTitle") If @error Or Not IsArray($aReturn) Then Return SetError(1, 0, 0) If Not $aReturn[0] Then Return SetError(2, 0, 0) Return $aReturn[0] EndFunc Func uFMOD_Jump2Pattern($iPattern) DllCall($g_iDLLPath, "none", "uFMOD_Jump2Pattern", "long", $iPattern) Return 1 EndFunc uFMOD_PlaySongFile(<YOUR XM FILE>) ;<<<<<<<<<<<<<<<<<<< change it While Sleep(10) If uFMOD_GetTime() > 10000 Then ExitLoop WEnd uFMOD_StopSong() DllClose($g_iDLLPath) Important is to load the DLL via DllOpen() otherwise it will crash.
-
You may have a look here:
-
Try $return = DllCall($hDLL, "int", "uFMOD_PlaySong", "str", $xm, "uint", 0, "uint", 2) "STR*" is a string pointer which is wrong here. Before exiting the script I would suggest to stop the player by DllCall($hDLL, "int", "uFMOD_PlaySong", "str", 0, "uint", 0, "uint", 0)
-
Add a bevel to image using GDIPlus
UEZ replied to benners's topic in AutoIt General Help and Support
Looks nice. I modified my example above a little bit: ;Coded by UEZ build 2024-06-27 #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global Const $STM_SETIMAGE = 0x0172 _GDIPlus_Startup() ;initialize GDI+ Global Const $iWidth = 600, $iHeight = 300, $iBgColor = 0x303030 ;$iBgColor format RRGGBB Global $hGUI = GUICreate("GDI+ Test", $iWidth, $iHeight) ;create a test GUI GUISetBkColor($iBgColor, $hGUI) ;set GUI background color GUISetState(@SW_SHOW) Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing) Global $iW = $iWidth * 0.8, $iH = 30 Global $aImage_PB1 = _GDIPlus_BitmapCreateProgressbar($iW, $iH, 0xFFFFFF00, 0, 0, 1) Global $aImage_PB2 = _GDIPlus_BitmapCreateProgressbar($iW, $iH, 0xFF400000, 0xFFFF4040, 0, 2) Global $aImage_PB3 = _GDIPlus_BitmapCreateProgressbar($iW, $iH, 0xFF004000, 0xFF40FF40, 0xF0E0FFE0, 3, $iW / 2, $iH / 2) _GDIPlus_GraphicsDrawImageRect($hGraphics, $aImage_PB1[0], ($iWidth - $iW) / 2, $iHeight * 0.10, $iW, $iH) _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $aImage_PB1[1], 0, 0, $iW / 2, $iH, ($iWidth - $iW) / 2, $iHeight * 0.10, $iW / 2, $iH) _GDIPlus_GraphicsDrawImageRect($hGraphics, $aImage_PB2[0], ($iWidth - $iW) / 2, $iHeight * 0.40, $iW, $iH) _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $aImage_PB2[1], 0, 0, $iW / 2, $iH, ($iWidth - $iW) / 2, $iHeight * 0.40, $iW / 2, $iH) _GDIPlus_GraphicsDrawImageRect($hGraphics, $aImage_PB3[0], ($iWidth - $iW) / 2, $iHeight * 0.70, $iW, $iH) _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $aImage_PB3[1], 0, 0, $iW / 2, $iH, ($iWidth - $iW) / 2, $iHeight * 0.70, $iW / 2, $iH) Global $iSleep = 10, $fProgress = 0, $aPos = WinGetPos($hGUI) Global $hGUI_PB = GUICreate("Progressbar Example", $iW + 10, $iH + 10, -1, $aPos[1] + $aPos[3] - $iH) Global $iPB = GUICtrlCreatePic("", 5, 5, $iW, $iH), $hPB = GUICtrlGetHandle($iPB) GUISetState(@SW_SHOW, $hGUI_PB) GUIRegisterMsg($WM_TIMER, "SetProgressbar") DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIRegisterMsg($WM_TIMER, "") ;cleanup GDI+ resources _GDIPlus_ImageDispose($aImage_PB1[0]) _GDIPlus_ImageDispose($aImage_PB1[1]) _GDIPlus_ImageDispose($aImage_PB2[0]) _GDIPlus_ImageDispose($aImage_PB2[1]) _GDIPlus_ImageDispose($aImage_PB3[0]) _GDIPlus_ImageDispose($aImage_PB3[1]) _WinAPI_DeleteObject($aImage_PB1[2]) _WinAPI_DeleteObject($aImage_PB1[3]) _WinAPI_DeleteObject($aImage_PB2[2]) _WinAPI_DeleteObject($aImage_PB2[3]) _WinAPI_DeleteObject($aImage_PB3[2]) _WinAPI_DeleteObject($aImage_PB3[3]) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete($hGUI) Func SetProgressbar() $fProgress = Mod($fProgress + 0.1, 100) Local $fP = Max(Min(100, $fProgress), 0) Local $fWidth = $fP / 100 * $iW Static $cx = 0 Local $aBitmap = _GDIPlus_BitmapCreateProgressbar($iW, $iH, 0xFF004000, 0xFF40FF40, 0xF0E0FFE0, 3, Abs(Sin($cx / 100) * 2 * $iW) - $iW, $iH / 2) $cx += 1 Local Const $hBmp = _GDIPlus_BitmapCloneArea($aImage_PB3[0], 0, 0, $iW, $iH, $GDIP_PXF32ARGB), _ $hGfx = _GDIPlus_ImageGetGraphicsContext($hBmp) _GDIPlus_GraphicsDrawImageRectRect($hGfx, $aBitmap[1], 0, 0, $fWidth, $iH, 0, 0, $fWidth, $iH) Local Const $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000) Local Const $hFormat = _GDIPlus_StringFormatCreate() Local Const $hFamily = _GDIPlus_FontFamilyCreate("Arial") Local Const $hFont = _GDIPlus_FontCreate($hFamily, $iH / 3, 0) Local Const $tLayout = _GDIPlus_RectFCreate(0, 0, $iW, $iH) _GDIPlus_StringFormatSetAlign($hFormat, 1) _GDIPlus_StringFormatSetLineAlign($hFormat, 1) _GDIPlus_GraphicsDrawStringEx($hGfx, Int($fP) & "%", $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_BrushDispose($hBrush) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontDispose($hFont) Local Const $hBmp_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp) Local Const $hB = GUICtrlSendMsg($iPB, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp_GDI) If $hB Then _WinAPI_DeleteObject($hB) _GDIPlus_ImageDispose($hBmp) _GDIPlus_GraphicsDispose($hGfx) _WinAPI_DeleteObject($hBmp_GDI) _GDIPlus_ImageDispose($aBitmap[0]) _GDIPlus_ImageDispose($aBitmap[1]) _WinAPI_DeleteObject($aBitmap[2]) _WinAPI_DeleteObject($aBitmap[3]) EndFunc Func Max($a, $b) Return $a > $b ? $a : $b EndFunc Func Min($a, $b) Return $a < $b ? $a : $b EndFunc Func _GDIPlus_BitmapCreateProgressbar($iW, $iH, $iStartColor = 0xFF004000, $iEndColor = 0xFF40FF40, $iCenterColor = 0xF0E0FFE0, $iMode = 3, $fXC = 0, $fCY = 0, $iBlur = 5, $iWrapMode = 3) Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) Local $hBrush, $hPath = _GDIPlus_PathCreate() Switch $iMode Case 1 $hBrush = _GDIPlus_BrushCreateSolid($iStartColor) Case 2 Local $tRECTF = _GDIPlus_RectFCreate(0, 0, $iW, $iH / 2) $hBrush = _GDIPlus_LineBrushCreateFromRectWithAngle($tRECTF, $iStartColor, $iEndColor, 90, False, $iWrapMode) _GDIPlus_LineBrushSetGammaCorrection($hBrush, True) Case 3 $hBrush = _GDIPlus_BrushCreateSolid($iStartColor) _GDIPlus_GraphicsFillRect($hCtxt, 0, 0, $iW, $iH, $hBrush) _GDIPlus_BrushDispose($hBrush) _GDIPlus_PathAddRectangle($hPath, 0, 0, $iW, $iH) $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath) Local $aColors[3] = [2, $iStartColor, $iEndColor] _GDIPlus_PathBrushSetSurroundColorsWithCount($hBrush, $aColors) _GDIPlus_PathBrushSetCenterColor($hBrush, $iCenterColor) _GDIPlus_PathBrushSetCenterPoint($hBrush, $fXC, $fCY) _GDIPlus_PathBrushSetWrapMode($hBrush, $iWrapMode) _GDIPlus_PathBrushSetGammaCorrection($hBrush, True) EndSwitch _GDIPlus_GraphicsFillRect($hCtxt, 0, 0, $iW, $iH, $hBrush) _GDIPlus_BrushDispose($hBrush) Local $iColor Switch $iMode Case 1 $iColor = ColorChange($iStartColor, 0.4) Case 2 $iColor = 0x20FFFFFF Case 3 $iColor = 0x60FFFFFF EndSwitch $hBrush = _GDIPlus_BrushCreateSolid($iColor) _GDIPlus_GraphicsFillRect($hCtxt, 0, $iH * 0.85, $iW, $iH, $hBrush) Switch $iMode Case 1 $iColor = ColorChange($iStartColor, 0.5) Case 2 $iColor = ColorChange($iStartColor) Case 3 $iColor = ColorChange($iStartColor) EndSwitch _GDIPlus_BrushSetSolidColor($hBrush, $iColor) _GDIPlus_GraphicsFillRect($hCtxt, 0, 0, $iW * 0.03, $iH, $hBrush) _GDIPlus_GraphicsFillRect($hCtxt, $iW * 0.97, 0, $iW, $iH, $hBrush) Switch $iMode Case 1 $iColor = ColorChange($iStartColor, 0.1) Case 2 $iColor = 0x40FFFFFF Case 3 $iColor = 0x50FFFFFF EndSwitch _GDIPlus_BrushSetSolidColor($hBrush, $iColor) _GDIPlus_GraphicsFillRect($hCtxt, 0, 0, $iW, $iH * 0.225, $hBrush) Local $hEffect = _GDIPlus_EffectCreateBlur($iBlur) _GDIPlus_BitmapApplyEffect($hBitmap, $hEffect) _GDIPlus_EffectDispose($hEffect) Local $hBitmap_Bg = _GDIPlus_BitmapCloneArea($hBitmap, 0, 0, $iW, $iH, $GDIP_PXF32ARGB) Local $tColorMatrix = _GDIPlus_ColorMatrixCreateGrayScale() $hEffect = _GDIPlus_EffectCreateColorMatrix($tColorMatrix) _GDIPlus_BitmapApplyEffect($hBitmap_Bg, $hEffect) _GDIPlus_EffectDispose($hEffect) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hCtxt) _GDIPlus_PathDispose($hPath) Local $aBitmaps[] = [$hBitmap_Bg, $hBitmap, _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Bg), _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)] Return $aBitmaps EndFunc Func ColorChange($iColor, $fFactor = 0.99) Local $iR = BitShift(BitAND($iColor, 0xFF0000), 16), $iG = BitShift(BitAND($iColor, 0xFF00), 8), $iB = BitAND($iColor, 0xFF) Return BitOR(BitAND($iColor, 0x20000000), BitShift($iR * $fFactor, -16), BitShift($iG * $fFactor, -8), $iB * $fFactor) EndFunc -
Add a bevel to image using GDIPlus
UEZ replied to benners's topic in AutoIt General Help and Support
Here something you can play with: ;Coded by UEZ build 2024-06-25 #include <GDIPlus.au3> #include <GUIConstantsEx.au3> _GDIPlus_Startup() ;initialize GDI+ Global Const $iWidth = 600, $iHeight = 300, $iBgColor = 0x303030 ;$iBgColor format RRGGBB Global $hGUI = GUICreate("GDI+ Test", $iWidth, $iHeight) ;create a test GUI GUISetBkColor($iBgColor, $hGUI) ;set GUI background color GUISetState(@SW_SHOW) Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing) Global $iW = $iWidth * 0.8, $iH = 30 Global $hImage_PB1 = _GDIPlus_BitmapCreateProgressbar($iW, $iH, 0xFFFFFF00, 0, 0, 1) Global $hImage_PB2 = _GDIPlus_BitmapCreateProgressbar($iW, $iH, 0xFF400000, 0xFFFF4040, 0, 2) Global $hImage_PB3 = _GDIPlus_BitmapCreateProgressbar($iW, $iH) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage_PB1, ($iWidth - $iW) / 2, $iHeight * 0.10, $iW, $iH) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage_PB2, ($iWidth - $iW) / 2, $iHeight * 0.40, $iW, $iH) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage_PB3, ($iWidth - $iW) / 2, $iHeight * 0.70, $iW, $iH) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ;cleanup GDI+ resources _GDIPlus_ImageDispose($hImage_PB1) _GDIPlus_ImageDispose($hImage_PB2) _GDIPlus_ImageDispose($hImage_PB3) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete($hGUI) Func _GDIPlus_BitmapCreateProgressbar($iW, $iH, $iStartColor = 0xFF004000, $iEndColor = 0xFF40FF40, $iCenterColor = 0xF0E0FFE0, $iMode = 3, $iBlur = 5, $iWrapMode = 3) Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) Local $hBrush, $hPath = _GDIPlus_PathCreate() Switch $iMode Case 1 $hBrush = _GDIPlus_BrushCreateSolid($iStartColor) Case 2 Local $tRECTF = _GDIPlus_RectFCreate(0, 0, $iW, $iH / 2) $hBrush = _GDIPlus_LineBrushCreateFromRectWithAngle($tRECTF, $iStartColor, $iEndColor, 90, False, $iWrapMode) _GDIPlus_LineBrushSetGammaCorrection($hBrush, True) Case 3 $hBrush = _GDIPlus_BrushCreateSolid($iStartColor) _GDIPlus_GraphicsFillRect($hCtxt, 0, 0, $iW, $iH, $hBrush) _GDIPlus_BrushDispose($hBrush) _GDIPlus_PathAddRectangle($hPath, 0, 0, $iW, $iH) $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath) Local $aColors[3] = [2, $iStartColor, $iEndColor] _GDIPlus_PathBrushSetSurroundColorsWithCount($hBrush, $aColors) _GDIPlus_PathBrushSetCenterColor($hBrush, $iCenterColor) _GDIPlus_PathBrushSetCenterPoint($hBrush, $iW / 2, $iH / 2) _GDIPlus_PathBrushSetWrapMode($hBrush, $iWrapMode) _GDIPlus_PathBrushSetGammaCorrection($hBrush, True) EndSwitch _GDIPlus_GraphicsFillRect($hCtxt, 0, 0, $iW, $iH, $hBrush) _GDIPlus_BrushDispose($hBrush) Local $iColor Switch $iMode Case 1 $iColor = ColorChange($iStartColor, 0.4) Case 2 $iColor = 0x20FFFFFF Case 3 $iColor = 0x60FFFFFF EndSwitch $hBrush = _GDIPlus_BrushCreateSolid($iColor) _GDIPlus_GraphicsFillRect($hCtxt, 0, $iH * 0.85, $iW, $iH, $hBrush) Switch $iMode Case 1 $iColor = ColorChange($iStartColor, 0.5) Case 2 $iColor = ColorChange($iStartColor) Case 3 $iColor = ColorChange($iStartColor) EndSwitch _GDIPlus_BrushSetSolidColor($hBrush, $iColor) _GDIPlus_GraphicsFillRect($hCtxt, 0, 0, $iW * 0.03, $iH, $hBrush) _GDIPlus_GraphicsFillRect($hCtxt, $iW * 0.97, 0, $iW, $iH, $hBrush) Switch $iMode Case 1 $iColor = ColorChange($iStartColor, 0.1) Case 2 $iColor = 0x40FFFFFF Case 3 $iColor = 0x50FFFFFF EndSwitch _GDIPlus_BrushSetSolidColor($hBrush, $iColor) _GDIPlus_GraphicsFillRect($hCtxt, 0, 0, $iW, $iH * 0.225, $hBrush) Local $hEffect = _GDIPlus_EffectCreateBlur($iBlur) _GDIPlus_BitmapApplyEffect($hBitmap, $hEffect) _GDIPlus_EffectDispose($hEffect) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hCtxt) _GDIPlus_PathDispose($hPath) Return $hBitmap EndFunc Func ColorChange($iColor, $fFactor = 0.99) Local $iR = BitShift(BitAND($iColor, 0xFF0000), 16), $iG = BitShift(BitAND($iColor, 0xFF00), 8), $iB = BitAND($iColor, 0xFF) Return BitOR(BitAND($iColor, 0x20000000), BitShift($iR * $fFactor, -16), BitShift($iG * $fFactor, -8), $iB * $fFactor) EndFunc