I can cut image as I want, but the problem is that the inner border is not anti-aliased (like the outer border).
I tried 2 different methods, but no success. What am I doing wrong? Do I have to call Gdip_LockBits() and Gdip_UnlockBits()? How?
How to make anti-aliased inner border?
Thank you in advance.
; Press F1, F2, F3 ... ;===Auto-execute======================================================================== ;===Create LayeredWindow=== #NoEnv w := 350, h := 350 OnExit, ExitSub Gui 1: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs +HwndhGui Gui 1: Show, NA OnMessage(0x201, "WM_LBUTTONDOWN") pToken := Gdip_Startup() hbm := CreateDIBSection(w, h), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm) G := Gdip_GraphicsFromHDC(hdc), Gdip_SetSmoothingMode(G, 4) pBrush1 := Gdip_CreateLineBrushFromRect(0, 0, w, h, 0xaa777777, 0xff111111) ; for background Gdip_FillEllipse(G, pBrush1, 1, 1, w-2, h-2) ; fill background UpdateLayeredWindow(hGui, hdc, (A_ScreenWidth-w)//2, (A_ScreenHeight-h)//2, w, h) ;===Create path which will later be used for cutting the image=== Offsets := "-32:-90|18:-61|18:-3|-32:26|-82:-3|-82:-61|-32:-143|24:-128|64:-88|79:-32|64:24|24:64|-32:79|-88:64|-128:24|-143:-32|-128:-88|-88:-128" ; Offsets are relative to the center of image pPath := Gdip_CreatePath(1) ; BrushMode: Winding = 1 Loop, parse, Offsets, | { StringSplit, coordinate, A_LoopField, : Gdip_AddPathEllipse(pPath, w/2+coordinate1, w/2+coordinate2, 64, 64) } return ;===Hotkeys============================================================================= F1:: ; First cutting method: Set clip to path, and then clear that area in Graphics Gdip_GraphicsClear(G) Gdip_FillEllipse(G, pBrush1, 1, 1, w-2, h-2) ; fill background Gdip_SetClipPath(G, pPath, 0) ; CombineMode: Replace = 0, Intersect = 1, Union = 2, Xor = 3, Exclude = 4, Complement = 5 Gdip_GraphicsClear(G) ; clear just that area in Graphics Gdip_ResetClip(G) ; now we can draw on entire Graphics again UpdateLayeredWindow(hGui, hdc) return F2:: ; Second cutting method: Overwrite path with transparent brush Gdip_GraphicsClear(G) Gdip_FillEllipse(G, pBrush1, 1, 1, w-2, h-2) ; fill background pBrush2 := Gdip_BrushCreateSolid("0x00000000") Gdip_SetCompositingMode(G, 1) ; 0 = blended, 1 = overwrite Gdip_FillPath(G, pBrush2, pPath) ; overwrite with transparent brush Gdip_SetCompositingMode(G, 0) ; back to default mode; blended Gdip_DeleteBrush(pBrush2) UpdateLayeredWindow(hGui, hdc) return F3:: ; Back to initial state (image is not cut) Gdip_GraphicsClear(G) Gdip_FillEllipse(G, pBrush1, 1, 1, w-2, h-2) ; fill background UpdateLayeredWindow(hGui, hdc) return Esc::ExitApp ;===Subroutines========================================================================= ExitSub: Gdip_DeleteBrush(pBrush1), Gdip_DeletePath(pPath) SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc), Gdip_DeleteGraphics(G) Gdip_Shutdown(pToken) ExitApp ;===Functions=========================================================================== #Include Gdip.ahk ; by Tic www.autohotkey.com/community/viewtopic.php?f=2&t=32238 WM_LBUTTONDOWN() { PostMessage, 0xA1, 2 }