解决方案 »

  1.   

    css的话,不是裁切,只是把图片设成背景,然后调整背景图的位置。现在网站优化中 有一个Image Sprites讲的就是这个,就是把所有常用的图片拼成一张大图,然后可以通过CSS在不同的地方显示图片中的不同区域。
    百度百科介绍:
    hthttp://baike.baidu.com/view/2173476.htmcss sprite
      

  2.   

    剪切图片功能
    private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
            {
                isDrag = false;
                ig = pictureBox1.CreateGraphics(); //创建pictureBox1控件的Graphics类
                //绘制矩形框
                ig.DrawRectangle(new Pen(Color.Black, 1), startPoint.X, startPoint.Y, e.X - startPoint.X, e.Y - startPoint.Y);
                theRectangle = new Rectangle(startPoint.X, startPoint.Y, e.X - startPoint.X, e.Y - startPoint.Y); //获得矩形框的区域
            }        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
            {
                Graphics g = this.CreateGraphics(); //为当前窗体创建Graphics类
                if (isDrag) //如果鼠示已按下
                {
                    //绘制一个矩形框
                    g.DrawRectangle(new Pen(Color.Black, 1), startPoint.X, startPoint.Y, e.X - startPoint.X, e.Y - startPoint.Y);
                }
            }        private void Form1_MouseClick(object sender, MouseEventArgs e)
            {
                try
                {
                    Graphics graphics = this.CreateGraphics(); //为当前窗体创建Graphics类
                    Bitmap bitmap = new Bitmap(pictureBox1.Image); //实例化Bitmap类
                    Bitmap cloneBitmap = bitmap.Clone(theRectangle, PixelFormat.DontCare);//通过剪切图片的大小实例化Bitmap类
                    graphics.DrawImage(cloneBitmap, e.X, e.Y); //绘制剪切的图片
                    Graphics g = pictureBox1.CreateGraphics();
                    SolidBrush myBrush = new SolidBrush(Color.White); //定义画刷CodeGo.net/
                    g.FillRectangle(myBrush, theRectangle); //绘制剪切后的图片
                }
                catch { }
            }
      

  3.   

    你做的是网页吗?如果是的话,我建了一个演示页面,你点进去自己看一下,使用的图片就是这一张,但是在三个链接上都都是用了,而且每个链接只显示其中的一部分。width和height设置显示的区域的大小,background后面的数字设置显示图片的顶点坐标。你可以更改右上角的部分然后点击上面的Run来看效果。