Region::GetRegionScans(constMatrix*,RectF*,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(
  const Matrix *matrix,
  RectF        *rects,
  INT          *count
);

Parameters

matrix

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

rects

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

count

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_GetRegionScansRectF(HDC hdc)
{
   Graphics graphics(hdc);

   SolidBrush solidBrush(Color(255, 255, 0, 0));
   Pen pen(Color(255, 0, 0, 0));
   GraphicsPath path;
   Matrix matrix;
   RectF* 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 = (RectF*)malloc(count*sizeof(RectF));
   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
Header gdiplusheaders.h

See also

Region

Matrix

Rect

Status

Region::GetRegionScansCount

Hit Testing with a Region

Regions