Help Center

GdipCombineRegionRegionfunction

Updates this region to the portion of itself that intersects another region.

Graphicsfunctiondocumented

Syntax

FUNCTION GdipCombineRegionRegion (BYVAL region AS GpRegion PTR, BYVAL region2 AS GpRegion PTR, BYVAL combineMode AS CombineMode) AS GpStatus

Parameters

NameDescription
region[in] Pointer to the Region object.
region2[in] Pointer to a Region object to use to update an existing Region object.
combineMode[in] Member of the CombineMode enumeration that specifies how the regions are combined.

Description

Updates this region to the portion of itself that intersects another region.

Example

' ======================================================================================== ' The following example creates a region from a path and then uses a rectangle to update ' the region. ' ======================================================================================== SUB Example_CombineRegionRegion (BYVAL hdc AS HDC)

DIM hStatus AS LONG

' // Create a graphics object from the device context DIM graphics AS GpGraphics PTR hStatus = GdipCreateFromHDC(hdc, @graphics)

' // Get the DPI scaling ratios DIM dpiX AS SINGLE hStatus = GdipGetDpiX(graphics, @dpiX) DIM rxRatio AS SINGLE = dpiX / 96 DIM dpiY AS SINGLE hStatus = GdipGetDpiY(graphics, @dpiY) Dim ryRatio AS SINGLE = dpiY / 96 ' // Set the scale transform hStatus = GdipScaleWorldTransform(graphics, rxRatio, ryRatio, MatrixOrderPrepend)

' // Create a Path DIM path AS GpPath PTR hStatus = GdipCreatePath(FillModeAlternate, @path)

' // Add a closed curve to the Path DIM pts(5) AS GpPointF pts(0).x = 110 : pts(0).y = 20 pts(1).x = 120 : pts(1).y = 30 pts(2).x = 100 : pts(2).y = 60 pts(3).x = 120 : pts(3).y = 70 pts(4).x = 150 : pts(4).y = 60 pts(5).x = 140 : pts(5).y = 10 hStatus = GdipAddPathClosedCurve(path, @pts(0), 6)

' // Create a region from a path. DIM pathRegion AS GpRegion PTR hStatus = GdipCreateRegionPath(path, @pathRegion)

' // Create a Region from a rectangle. DIM rcf AS GpRectF = (65, 15, 70, 45) DIM rectRegion AS GpRegion PTR hStatus = GdipCreateRegionRect(@rcf, @rectRegion)

' // Exclude a rectangle region from the path region. hStatus = GdipCombineRegionRegion(pathRegion, rectRegion, CombineModeIntersect)

' // Fill the union of the two regions with a red brush. DIM solidBrush AS GpSolidFill PTR hStatus = GdipCreateSolidFill(ARGB_RED, @solidBrush) hStatus = GdipFillRegion(graphics, solidBrush, pathRegion)

' // Cleanup IF rectRegion THEN GdipDeleteRegion(rectRegion) IF pathRegion THEN GdipDeleteRegion(pathRegion) IF solidBrush THEN GdipDeleteBrush(solidBrush) IF path THEN GdipDeletePath(path) IF graphics THEN GdipDeleteGraphics(graphics)

END SUB ' ========================================================================================

Reference

  • Defined in AfxNova/AfxGdiPlus.bi:2363
  • Documented in Graphics/GdiPlus Flat Api/GdiPlusRegion.md
  • Topic: GdiPlusRegion