我想在pictureBox中显示图像的时候,指定图像的一块地方来显示
即指明坐标来显示图像
请问高手如何解决~
谢谢

解决方案 »

  1.   

    Graphics g = pictureBox1.CreateGraphics();
    g.DrawImage(pictureBox1.Image,
                  new Rectangle(0, 0, xWidth, yHeight),  //where to draw the image
                  new Rectangle(x, y, xWidth, yHeight),  //the portion of the image to draw x,y是自己定义的大小.
                  GraphicsUnit.Pixel); 
    具体可参考MSDN的Graphics.DrawImage()方法.有好多重载.
      

  2.   

    Graphics g = pictureBox1.CreateGraphics(); 
    g.DrawImage(pictureBox1.Image, 
                  new Rectangle(300, 300, 300,300),
                  GraphicsUnit.Pixel); 我用这个它说重载方法有无效参数。。
    然后我把那个指定单位是像素的GraphicsUnit.Pixel去掉
    没错了 可是运行了之后图像显示没变化啊
      

  3.   

    C#
    public void DrawImage (
        Image image,
        RectangleF destRect,
        RectangleF srcRect,
        GraphicsUnit srcUnit
    )
    参数
    image
    要绘制的 Image。 destRect
    RectangleF 结构,它指定所绘制图像的位置和大小。将图像进行缩放以适合该矩形。 srcRect
    RectangleF 结构,它指定 image 对象中要绘制的部分。 srcUnit
    GraphicsUnit 枚举的成员,它指定 srcRect 参数所用的度量单位。 
    恩,找到代码了
      

  4.   

    语法没问题了  可是没实现
    代码段我是放在指定了pictureBox的图像地址之后,应该没问题的吧?
      

  5.   

    加一句
    pictureBox1.Update();
      

  6.   

    重载PictureBox的重绘方法吧,可以给继承而来的PictureBox子类新添属性用于绘制图片指定区域