Function Reference


_GDIPlus_RegionCombineRegion

Updates a region to the portion of itself that intersects another region

#include <GDIPlus.au3>
_GDIPlus_RegionCombineRegion ( $hRegionDst, $hRegionSrc [, $iCombineMode = 2] )

Parameters

$hRegionDst Pointer to a Region object
$hRegionSrc Pointer to a Region object to use to update the $hRegionDst Region object
$iCombineMode [optional] Combine mode that specifies how the regions are combined:
    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.
A point is in the XOR of two regions if it is in one region or the other but not in both 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 Value

Success: True.
Failure: False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPIP_ERR* see GPIPlusConstants.au3).

Related

_GDIPlus_RegionCombinePath, _GDIPlus_RegionCombineRect

See Also

Search GdipCombineRegionRegion in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
        Local $hGUI, $hGraphic, $hBrush, $hRegion, $hRegion1, $hRegion2, $hPath

        ; Create GUI
        $hGUI = GUICreate("GDI+", 600, 480)
        GUISetState(@SW_SHOW)

        _GDIPlus_Startup()
        $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
        _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

        $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA)

        $hPath = _GDIPlus_PathCreate() ;Create new path object
        _GDIPlus_PathAddEllipse($hPath, 80, 60, 80, 60)

        $hRegion1 = _GDIPlus_RegionCreateFromRect(30, 80, 80, 60)
        $hRegion2 = _GDIPlus_RegionCreateFromPath($hPath)

        _GDIPlus_GraphicsDrawString($hGraphic, "2 regions", 50, 30)
        _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion1, $hBrush)
        _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion2, $hBrush)

        _GDIPlus_GraphicsDrawString($hGraphic, "intersection", 50, 180)
        _GDIPlus_RegionTranslate($hRegion1, 0, 150)
        _GDIPlus_RegionTranslate($hRegion2, 0, 150)
        $hRegion = _GDIPlus_RegionClone($hRegion1)
        _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 1) ;intersection
        _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
        _GDIPlus_RegionDispose($hRegion)

        _GDIPlus_GraphicsDrawString($hGraphic, "union", 250, 180)
        _GDIPlus_RegionTranslate($hRegion1, 200, 0)
        _GDIPlus_RegionTranslate($hRegion2, 200, 0)
        $hRegion = _GDIPlus_RegionClone($hRegion1)
        _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 2) ;union
        _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
        _GDIPlus_RegionDispose($hRegion)

        _GDIPlus_GraphicsDrawString($hGraphic, "xor", 450, 180)
        _GDIPlus_RegionTranslate($hRegion1, 200, 0)
        _GDIPlus_RegionTranslate($hRegion2, 200, 0)
        $hRegion = _GDIPlus_RegionClone($hRegion1)
        _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 3) ;xor
        _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
        _GDIPlus_RegionDispose($hRegion)

        _GDIPlus_GraphicsDrawString($hGraphic, "region1 sub region2", 50, 330)
        _GDIPlus_RegionTranslate($hRegion1, -400, 150)
        _GDIPlus_RegionTranslate($hRegion2, -400, 150)
        $hRegion = _GDIPlus_RegionClone($hRegion1)
        _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 4) ;1 sub 2
        _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
        _GDIPlus_RegionDispose($hRegion)

        _GDIPlus_GraphicsDrawString($hGraphic, "region2 sub region1", 250, 330)
        _GDIPlus_RegionTranslate($hRegion1, 200, 0)
        _GDIPlus_RegionTranslate($hRegion2, 200, 0)
        $hRegion = _GDIPlus_RegionClone($hRegion1)
        _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 5) ;2 sub 1
        _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
        _GDIPlus_RegionDispose($hRegion)

        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE

        ; Clean up resources
        _GDIPlus_PathDispose($hPath)
        _GDIPlus_RegionDispose($hRegion1)
        _GDIPlus_RegionDispose($hRegion2)
        _GDIPlus_BrushDispose($hBrush)
        _GDIPlus_GraphicsDispose($hGraphic)
        _GDIPlus_Shutdown()
EndFunc   ;==>Example