Region.GetRegionScans(const Matrix*, RectF*, INT*) method
Applies to: desktop apps only
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] RectF *rects,
[out] INT *count
) const;
Parameters
matrix [in]
Type: const Matrix*Pointer to a Matrix object that is used to transform the region.
rects [out]
Type: RectF*Pointer to an array of RectF objects that receives the rectangles.
count [out]
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:
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
Minimum supported client |
Windows XP, Windows 2000 Professional |
Minimum supported server |
Windows 2000 Server |
Product |
GDI+ 1.0 |
Header |
Gdiplusheaders.h (include Gdiplus.h) |
Library |
Gdiplus.lib |
DLL |
Gdiplus.dll |
See also
Send comments about this topic to Microsoft
Build date: 3/6/2012