Region::GetRegionScans(constMatrix*,Rect*,INT*) method (gdiplusheaders.h)

The Region::GetRegionScans method gets an array of rectangles that approximate this region. The region is transformed by a specified matrix before the rectangles are calculated.

Syntax

Status GetRegionScans(
  [in]  const Matrix *matrix,
  [out] Rect         *rects,
  [out] INT          *count
);

Parameters

[in] matrix

Type: const Matrix*

Pointer to a Matrix object that is used to transform the region.

[out] rects

Type: Rect*

Pointer to an array of Rect objects that receives the rectangles.

[out] count

Type: INT*

Pointer to an INT that receives a value that indicates the number of rectangles that approximate this region. The value is valid even if rects is a NULL pointer.

Return value

Type: Status

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

If the method fails, it returns one of the other elements of the Status enumeration.

Remarks

The Region::GetRegionScansCount method can be used first to determine the number of rectangles. Then, you can allocate a buffer that is the correct size and set the rects parameter to point to the buffer.

Examples

The following example creates a region from a path and gets a set of rectangles that approximate the region. The code then draws each of the rectangles.

VOID Example_GetRegionScansRect(HDC hdc)
{
   Graphics graphics(hdc);

   SolidBrush solidBrush(Color(255, 255, 0, 0));
   Pen pen(Color(255, 0, 0, 0));
   GraphicsPath path;
   Matrix matrix;
   Rect* rects = NULL;
   INT count = 0;  

   // Create a region from a path.
   path.AddEllipse(10, 10, 50, 300);
   Region pathRegion(&path);    
   graphics.FillRegion(&solidBrush, &pathRegion);

   // Get the rectangles.
   graphics.GetTransform(&matrix);
   count = pathRegion.GetRegionScansCount(&matrix);
   rects = (Rect*)malloc(count*sizeof(Rect));
   pathRegion.GetRegionScans(&matrix, rects, &count);  

   // Draw the rectangles.
   for(INT j = 0; j < count; ++j)
      graphics.DrawRectangle(&pen, rects[j]);

   free(rects);
}

Requirements

Requirement Value
Minimum supported client Windows XP, Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header gdiplusheaders.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

Hit Testing with a Region

Matrix

Rect

Region

Region::GetRegionScansCount

Regions

Status