• 图形技术(局部图片放大)


    界面:

    核心代码: 

    Cursor myCursor = new Cursor(@"C:\WINDOWS\Cursors\aero_cross.cur"); //自定义鼠标 
      Image myImage;

    //选择图片

     private void button1_Click(object sender, EventArgs e)
            {
                openFileDialog1.Filter = "*.jpg,*.jpeg,*.bmp,*.gif,*.ico,*.png,*.tif,*.wmf|*.jpg;*.jpeg;*.bmp;*.gif;*.ico;*.png;*.tif;*.wmf";
                openFileDialog1.ShowDialog();
                myImage = System.Drawing.Image.FromFile(openFileDialog1.FileName);
                pictureBox1.Image = myImage;
                pictureBox1.Height = myImage.Height;
                pictureBox1.Width = myImage.Width;
            }

    //鼠标经过的地方放大

            private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
            {
                try
                {
                    Cursor.Current = myCursor;
                    Graphics graphics = pictureBox1.CreateGraphics();
                    Rectangle sourceRectangle = new Rectangle(e.X - 10, e.Y - 10, 20, 20); //要放大的区域
                    Rectangle destRectangle = new Rectangle(e.X - 20, e.Y - 20, 40, 40);
                    graphics.DrawImage(myImage, destRectangle, sourceRectangle, GraphicsUnit.Pixel);
                }
                catch
                { }
            }

  • 相关阅读:
    .net core 2.x默认不支持gb2312
    获取枚举描述
    C#中DateTime.Ticks
    验证组件FluentValidation的使用示例
    python计算出现错误
    EF的导航属性
    webpack不打包指定的js文件
    递归树处理,配合vue的vueTreeselect组件使用
    elementUI 日期时间选择器el-date-picker开始时间与结束时间约束
    Vue2+Webpack+ES6 兼容低版本浏览器(IE9)解决方案
  • 原文地址:https://www.cnblogs.com/msAspnet/p/2098984.html
Copyright © 2020-2023  润新知