局部图像放大

实现效果:

  

知识运用:

  DrawImage方法

  public void DrawImage (Image image, Point point)    //指定位置绘制原始大小图像

  publIc void DrawImage (Image image,Rectangel rect)    //指定位置绘制指定大小的Image图像

  publicvoid DrawImage (Image image, Point[] destPoints, Rectangle srcRect, GraphicsUnit srcUnit)  //指定大小绘制指定部分的图像

  # image      要绘制的Image图像

  # destImage    有三个Point结构组成的数组 这三个结构定义一个平行四边形

  # srcRect      Rectangle结构 指定image中要绘制的部分

  # srcUnit          GraphicsUnit枚举成员  指定srcRect参数所用的度量单位

实现代码:

        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            try
            {
                Cursor.Current = myCursor;                                          //定义鼠标  
                Rectangle rectangle = new Rectangle(e.X-10,e.Y-10,20,20);           //要放大的区域
                Rectangle destRectangle = new Rectangle(e.X-40,e.Y-40,80,80);
                Graphics graphics = pictureBox1.CreateGraphics();                   //创建pictureBox1控件的Graphics对象
                graphics.DrawImage(image,destRectangle,rectangle,GraphicsUnit.Pixel);
            }
            catch{}
        }

  

原文地址:https://www.cnblogs.com/feiyucha/p/10261259.html