Region::GetRegionScansCount 方法 (gdiplusheaders.h)

Region::GetRegionScansCount 方法會取得大約此區域的矩形數目。 在計算矩形之前,區域會由指定的矩陣轉換。

語法

UINT GetRegionScansCount(
  [in] const Matrix *matrix
);

參數

[in] matrix

類型: const 矩陣*

用來轉換區域的矩陣指標。

傳回值

類型: UINT

這個方法會傳回整數,指出近似這個區域的矩形數目。

備註

在 GetRegionScans 方法判斷矩形數目之前,可以使用 Region::GetRegionScansCount 方法。 然後,您可以配置大小正確的緩衝區,以儲存使用 GetRegionScans 方法取得的矩形。

範例

下列範例會從路徑建立區域,並取得一組近似區域的矩形。 然後,程式代碼會繪製每個矩形。

VOID Example_GetRegionScansCount(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);
}

規格需求

需求
最低支援的用戶端 Windows XP、Windows 2000 Professional [僅限桌面應用程式]
最低支援的伺服器 Windows 2000 Server [僅限桌面應用程式]
目標平台 Windows
標頭 gdiplusheaders.h (包含 Gdiplus.h)
程式庫 Gdiplus.lib
Dll Gdiplus.dll

另請參閱

矩陣

Rect

區域

Region::GetRegionScans 方法