日期:2014-05-18 浏览次数:21120 次
/// <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; }