110,539
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// 返回分割后的rectangle数组
/// </summary>
/// <param name="rt">待分割的矩形</param>
/// <param name="rowCount">行数</param>
/// <param name="colCount">列数</param>
/// <returns></returns>
public Rectangle[] GetSplittedRectangles(Rectangle rt, int rowCount,int colCount)
{
Rectangle[] rects = new Rectangle[rowCount * colCount];
int width = rt.Width / colCount;
int height = rt.Height / rowCount;
for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
{
for (int colIndex = 0; colIndex < colCount; colIndex++)
{
rects[rowIndex * colCount + colIndex] = new Rectangle(colIndex * width,
rowIndex * height, width, height);
}
}
return rects;
}