画像をいくつかの小さな画像に分割する
4340 ワード
1 ///
2 ///
3 /// , Rectangle ,
4 ///
5 ///
6 ///
7 ///
8 ///
9 public Bitmap[] SpliteImage(Bitmap bmpRes, int rowNum,int colNum)
10 {
11 Bitmap[] bmpaClipBmpArr = new Bitmap[rowNum * colNum];
12 for (int row = 0; row < rowNum; row++)
13 {
14 for (int col = 0; col < colNum; col++)
15 {
16 int nClipWidth = bmpRes.Width / colNum;
17 int nClipHight = bmpRes.Height / rowNum;
18
19 Rectangle rClipRect = new Rectangle(
20 nClipWidth * col,
21 nClipHight * row,
22 nClipWidth,
23 nClipHight );
24
25 int index = col + row * colNum;
26 bmpaClipBmpArr[index] = bmpRes.Clone(rClipRect, bmpRes.PixelFormat);
27 }
28 }
29 return bmpaClipBmpArr;
30 }
転載先:https://www.cnblogs.com/BKYZFSN/p/10913835.html