Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <WindowsConstants.au3>
- #include <GUIConstants.au3>
- #include <GDIPlus.au3>
- #include <WinAPI.au3>
- ; -Author: name22 (www.autoit.de)
- Opt("GUIOnEventMode", 1)
- Global $hWnd, $hDC_Window, $hDC_Bitmap, $hDC_Background, $hBitmap, $hBitmap_BG, $hImage_BG, $hOldObj, $hOldObj2, $hGraphics, $hPath_Hole, $sFile_BG
- $sFile_BG = FileOpenDialog("Image Selection", "", "Images (*.*)")
- If @error Then Exit
- Global $iWidth = 400
- Global $iHeight = 400
- Global $iRadiusHole = 80
- $hWnd = GUICreate("name22 example", $iWidth, $iHeight)
- GUISetState()
- $hDC_Window = _WinAPI_GetDC($hWnd)
- $hDC_Bitmap = _WinAPI_CreateCompatibleDC($hDC_Window)
- $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC_Window, $iWidth, $iHeight)
- $hOldObj = _WinAPI_SelectObject($hDC_Bitmap, $hBitmap)
- _GDIPlus_Startup()
- $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC_Bitmap)
- _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2)
- $hImage_BG = _GDIPlus_ImageLoadFromFile($sFile_BG)
- $hBitmap_BG = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage_BG)
- _GDIPlus_ImageDispose($hImage_BG)
- $hDC_Background = _WinAPI_CreateCompatibleDC($hDC_Window)
- $hOldObj2 = _WinAPI_SelectObject($hDC_Background, $hBitmap_BG)
- $hPath_Hole = _GDIPlus_PathCreate()
- OnAutoItExitRegister("_Shutdown")
- GUISetOnEvent($GUI_EVENT_CLOSE, "_Close")
- While Sleep(20)
- _WinAPI_BitBlt($hDC_Bitmap, 0, 0, $iWidth, $iHeight, $hDC_Background, 0, 0, $SRCCOPY)
- _GDIPlus_PathReset($hPath_Hole)
- _GDIPlus_PathAddEllipse($hPath_Hole, _WinAPI_GetMousePosX(True, $hWnd) - $iRadiusHole, _WinAPI_GetMousePosY(True, $hWnd) - $iRadiusHole, $iRadiusHole * 2, $iRadiusHole * 2)
- _GDIPlus_GraphicsSetClipPath($hGraphics, $hPath_Hole, 4)
- _GDIPlus_GraphicsClear($hGraphics)
- _GDIPlus_GraphicsResetClip($hGraphics)
- _WinAPI_BitBlt($hDC_Window, 0, 0, $iWidth, $iHeight, $hDC_Bitmap, 0, 0, $SRCCOPY)
- WEnd
- Func _Close()
- Exit
- EndFunc
- Func _Shutdown()
- _WinAPI_SelectObject($hDC_Bitmap, $hOldObj)
- _WinAPI_SelectObject($hDC_Background, $hOldObj2)
- _WinAPI_ReleaseDC($hWnd, $hDC_Window)
- _WinAPI_DeleteDC($hDC_Bitmap)
- _WinAPI_DeleteDC($hDC_Background)
- _WinAPI_DeleteObject($hBitmap)
- _WinAPI_DeleteObject($hBitmap_BG)
- _GDIPlus_GraphicsDispose($hGraphics)
- _GDIPlus_PathDispose($hPath_Hole)
- _GDIPlus_Shutdown()
- EndFunc
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _GDIPlus_PathCreate
- ; Description ...: Creates a GraphicsPath object and initializes the fill mode
- ; Syntax.........: _GDIPlus_PathCreate([$iFillMode = 0])
- ; Parameters ....: $iFillMode - Fill mode of the interior of the path figures:
- ; |0 - The areas are filled according to the even-odd parity rule
- ; |1 - The areas are filled according to the nonzero winding rule
- ; Return values .: Success - Pointer to a new GraphicsPath object
- ; Failure - 0 and either:
- ; |@error and @extended are set if DllCall failed
- ; |$GDIP_STATUS contains a non zero value specifying the error code
- ; Remarks .......: After you are done with the object, call _GDIPlus_PathDispose to release the object resources
- ; Related .......: _GDIPlus_PathCreate2, _GDIPlus_PathDispose
- ; Link ..........; @@MsdnLink@@ GdipCreatePath
- ; Example .......; No
- ; ===============================================================================================================================
- Func _GDIPlus_PathCreate($iFillMode = 0)
- Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", $iFillMode, "int*", 0)
- If @error Then Return SetError(@error, @extended, 0)
- $GDIP_STATUS = $aResult[0]
- Return $aResult[2]
- EndFunc ;==>_GDIPlus_PathCreate
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _GDIPlus_PathDispose
- ; Description ...: Releases a GraphicsPath object
- ; Syntax.........: _GDIPlus_PathDispose($hPath)
- ; Parameters ....: $hPath - Pointer to a GraphicsPath object
- ; Return values .: Success - True
- ; Failure - False and either:
- ; |@error and @extended are set if DllCall failed
- ; |$GDIP_STATUS contains a non zero value specifying the error code
- ; Remarks .......: None
- ; Related .......: _GDIPlus_PathCreate
- ; Link ..........; @@MsdnLink@@ GdipDeletePath
- ; Example .......; No
- ; ===============================================================================================================================
- Func _GDIPlus_PathDispose($hPath)
- Local $aResult = DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath)
- If @error Then Return SetError(@error, @extended, False)
- $GDIP_STATUS = $aResult[0]
- Return $aResult[0] = 0
- EndFunc ;==>_GDIPlus_PathDispose
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _GDIPlus_PathAddEllipse
- ; Description ...: Adds an ellipse to the current figure a path
- ; Syntax.........: _GDIPlus_PathAddEllipse($hPath, $nX, $nY, $nWidth, $nHeight)
- ; Parameters ....: $hPath - Pointer to a GraphicsPath object
- ; $nX - The X coordinate of the upper left corner of the rectangle that bounds the ellipse
- ; $nY - The Y coordinate of the upper left corner of the rectangle that bounds the ellipse
- ; $nWidth - The width of the rectangle that bounds the ellipse
- ; $nHeight - The height of the rectangle that bounds the ellipse
- ; Return values .: Success - True
- ; Failure - False and either:
- ; |@error and @extended are set if DllCall failed
- ; |$GDIP_STATUS contains a non zero value specifying the error code
- ; Remarks .......: None
- ; Related .......: None
- ; Link ..........; @@MsdnLink@@ GdipAddPathEllipse
- ; Example .......; No
- ; ===============================================================================================================================
- Func _GDIPlus_PathAddEllipse($hPath, $nX, $nY, $nWidth, $nHeight)
- Local $aResult = DllCall($ghGDIPDll, "uint", "GdipAddPathEllipse", "hwnd", $hPath, "float", $nX, "float", $nY, "float", $nWidth, "float", $nHeight)
- If @error Then Return SetError(@error, @extended, False)
- $GDIP_STATUS = $aResult[0]
- Return $aResult[0] = 0
- EndFunc ;==>_GDIPlus_PathAddEllipse
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _GDIPlus_PathReset
- ; Description ...: Empties a path and sets the fill mode to alternate (0)
- ; Syntax.........: _GDIPlus_PathReset($hPath)
- ; Parameters ....: $hPath - Pointer to a GraphicsPath object
- ; Return values .: Success - True
- ; Failure - False and either:
- ; |@error and @extended are set if DllCall failed
- ; |$GDIP_STATUS contains a non zero value specifying the error code
- ; Remarks .......: None
- ; Related .......: None
- ; Link ..........; @@MsdnLink@@ GdipResetPath
- ; Example .......; No
- ; ===============================================================================================================================
- Func _GDIPlus_PathReset($hPath)
- Local $aResult = DllCall($ghGDIPDll, "uint", "GdipResetPath", "hwnd", $hPath)
- If @error Then Return SetError(@error, @extended, False)
- $GDIP_STATUS = $aResult[0]
- Return $aResult[0] = 0
- EndFunc ;==>_GDIPlus_PathReset
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _GDIPlus_GraphicsSetClipPath
- ; Description ...: Updates the clipping region of this Graphics object to a region that is the combination of itself and the
- ; +region specified by a graphics path
- ; Syntax.........: _GDIPlus_GraphicsSetClipPath($hGraphics, $hPath[, $iCombineMode = 0])
- ; Parameters ....: $hGraphics - Pointer to a Graphics object
- ; $hPath - Pointer to a GraphicsPath object that specifies the region to be combined with the clipping
- ; +region of the Graphics object
- ; $iCombineMode - Regions combination mode:
- ; |0 - The existing region is replaced by the new region
- ; |1 - The existing region is replaced by the intersection of itself and the new region
- ; |2 - The existing region is replaced by the union of itself and the new region
- ; |3 - The existing region is replaced by the result of performing an XOR on the two regions
- ; |4 - The existing region is replaced by the portion of itself that is outside of the new region
- ; |5 - The existing region is replaced by the portion of the new region that is outside of the existing region
- ; Return values .: Success - True
- ; Failure - False and either:
- ; |@error and @extended are set if DllCall failed
- ; |$GDIP_STATUS contains a non zero value specifying the error code
- ; Remarks .......: If a figure in the path is not closed, this method treats the nonclosed figure as if it were closed by a
- ; +straight line that connects the figure's starting and ending points
- ; Related .......: None
- ; Link ..........; @@MsdnLink@@ GdipSetClipPath
- ; Example .......; No
- ; ===============================================================================================================================
- Func _GDIPlus_GraphicsSetClipPath($hGraphics, $hPath, $iCombineMode = 0)
- Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetClipPath", "hwnd", $hGraphics, "hwnd", $hPath, "int", $iCombineMode)
- If @error Then Return SetError(@error, @extended, False)
- $GDIP_STATUS = $aResult[0]
- Return $aResult[0] = 0
- EndFunc ;==>_GDIPlus_GraphicsSetClipPath
- ; #FUNCTION# ====================================================================================================================
- ; Name...........: _GDIPlus_GraphicsResetClip
- ; Description ...: Sets the clipping region of a Graphics object to an infinite region
- ; Syntax.........: _GDIPlus_GraphicsResetClip($hGraphics)
- ; Parameters ....: $hGraphics - Pointer to a Graphics object
- ; Return values .: Success - True
- ; Failure - False and either:
- ; |@error and @extended are set if DllCall failed
- ; |$GDIP_STATUS contains a non zero value specifying the error code
- ; Remarks .......: None
- ; Related .......: None
- ; Link ..........; @@MsdnLink@@ GdipResetClip
- ; Example .......; No
- ; ===============================================================================================================================
- Func _GDIPlus_GraphicsResetClip($hGraphics)
- Local $aResult = DllCall($ghGDIPDll, "uint", "GdipResetClip", "hwnd", $hGraphics)
- If @error Then Return SetError(@error, @extended, False)
- $GDIP_STATUS = $aResult[0]
- Return $aResult[0] = 0
- EndFunc ;==>_GDIPlus_GraphicsResetClip
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement