@iseahound Thank you, I read that post you provided and made some attempts, but the problem remains the same.
test code
Code: Select all
#SingleInstance, Force
#NoEnv
SetBatchLines, -1
#Include, Gdip_All.ahk
gosub, init
; Gdip_FillRoundedRectangle(G, pBrush, 0, 0, PicWidth-500, PicHeight, 20)
Gdip_FillRoundedRectanglePath(G, pBrush, 0, 0, PicWidth-500, PicHeight, 20)
UpdateLayeredWindow(hwnd1, hdc, 200, 200, DisplayAreaWidth, DisplayAreaHeight)
Return
Gdip_FillRoundedRectanglePath(pGraphics, pBrush, X, Y, W, H, R) {
; Create a GraphicsPath
DllCall("Gdiplus.dll\GdipCreatePath", "UInt", 0, "PtrP", pPath)
; Create a rounded rectabgle
D := (R * 2), W -= D, H -= D
DllCall("Gdiplus.dll\GdipAddPathArc", "Ptr", pPath, "Float", X, "Float", Y, "Float", D, "Float", D, "Float", 180, "Float", 90)
DllCall("Gdiplus.dll\GdipAddPathArc", "Ptr", pPath, "Float", X + W, "Float", Y, "Float", D, "Float", D, "Float", 270, "Float", 90)
DllCall("Gdiplus.dll\GdipAddPathArc", "Ptr", pPath, "Float", X + W, "Float", Y + H, "Float", D, "Float", D, "Float", 0, "Float", 90)
DllCall("Gdiplus.dll\GdipAddPathArc", "Ptr", pPath, "Float", X, "Float", Y + H, "Float", D, "Float", D, "Float", 90, "Float", 90)
DllCall("Gdiplus.dll\GdipClosePathFigure", "Ptr", pPath)
; Fill the path
RS := DllCall("Gdiplus.dll\GdipFillPath", "Ptr", pGraphics, "Ptr", pBrush, "Ptr", pPath)
; Free resources
DllCall("Gdiplus.dll\GdipDeletePath", "Ptr", pPath)
Return RS
}
init:
If !pToken := Gdip_Startup()
{
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
ExitApp
}
OnExit, Exit
Gui, 1: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs +Hwndhwnd1
Gui, 1: Show, NA
Loop, Files, %A_WinDir%\Web\WallPaper\*.jpg, R
ImgPath := A_LoopFileLongPath
pBitmap := Gdip_CreateBitmapFromFile(ImgPath)
If !pBitmap
{
MsgBox, 48, WallPaper loading error!
ExitApp
}
PicWidth := Gdip_GetImageWidth(pBitmap), PicHeight := Gdip_GetImageHeight(pBitmap)
DisplayAreaWidth:=A_ScreenWidth, DisplayAreaHeight:=A_ScreenHeight
hbm := CreateDIBSection(DisplayAreaWidth, DisplayAreaHeight)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_SetInterpolationMode(G, 7)
pBitmap:=Gdip_ResizeBitmap(pBitmap, PicWidth//3, PicHeight//3, 0)
PicWidth := Gdip_GetImageWidth(pBitmap), PicHeight := Gdip_GetImageHeight(pBitmap)
pBrush:= Gdip_CreateTextureBrush(pBitmap, WrapMode:=1)
Return
GuiClose:
GuiEscape:
Exit:
SelectObject(hdc, obm)
DeleteObject(hbm)
DeleteDC(hdc)
Gdip_DeleteGraphics(G)
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
ExitApp
Return