应用里 我想把一幅图分割成若干个小矩形,然后在一个容器里面分别显示,请问如何实现??
望各位给予提示~

解决方案 »

  1.   

    给你一个思路:
    将图片写到一个BitMap(当然需要创建一个Bitmap)上
    然后在Graphics类中有Clip工具。一个一个去裁吧。
    很麻烦的。具体没有做过
      

  2.   

    帮你做了个例子。这个例子把图像A平均分割成上下两部分,分别保存在图像b,和c中。            Bitmap A = new Bitmap("你要割的图片的路径");
               
                //利用图像A创建一个画布,以将A进行分割
                Graphics g = Graphics.FromImage(A);
                
                //创建两个位图用来保存分割后的图像
                Bitmap b = new Bitmap(A.Width, A.Height / 2);
                Bitmap c = new Bitmap(A.Width, A.Height / 2);            //把图像A的上半部分画到图像b上
                g.DrawImage(
                            b,
                            new Rectangle(0, 0, A.Width, A.Height / 2)
                            );            //把图像A的下半部分画到图像c上
                g.DrawImage(
                            c,
                            new Rectangle(0, A.Height/2, A.Width, A.Height / 2)
                            );