如何用C#把一张图片生成位图,再把它生成几个不重叠的部分啊?

解决方案 »

  1.   

    Bitmap bmp = new Bitmap("c:\\1.bmp");
    然后根据bmp的width和height,自己分隔开就行了
      

  2.   

     public static Bitmap[] SplitBitmap(Bitmap bmp, int ColNum,int RowNum)
            {
                int span=bmp.Width%ColNum;
                if (span != 0)
                {
                    Image.GetThumbnailImageAbort myCallback =new Image.GetThumbnailImageAbort(ThumbnailCallback);
                    bmp=(Bitmap)bmp.GetThumbnailImage(bmp.Width + (ColNum - span), bmp.Height, myCallback, IntPtr.Zero);  //???
                }
                int NewWidth = bmp.Width / ColNum;
                Bitmap[] tempMap = new Bitmap[ColNum];
                for (int i = 0; i < ColNum; i++)
                {
                    tempMap[i] = bmp.Clone(new Rectangle(i * NewWidth, 0, NewWidth, bmp.Height), bmp.PixelFormat);
                }
                return tempMap;
            }
    这样是不是可以把图片分成几列,如果加上行怎么改啊? bmp=(Bitmap)bmp.GetThumbnailImage(bmp.Width + (ColNum - span), bmp.Height, myCallback, IntPtr.Zero);第一个参数为什么要加上 (ColNum - span)什么意思啊?