【问题标题】:how to move a rectangle shape on jpeg image in asp.net?如何在asp.net中的jpeg图像上移动矩形?
【发布时间】:2015-01-05 06:36:42
【问题描述】:

分配给我的任务是在地图图像上使用矩形标记位置。矩形形状应该可以通过使用地图图像上的处理程序进行拖动来调整。我在图像上绘制了一个形状,但无法拖动以标记 jpeg 图像(地图图像)上的位置。之后,应将更新后的带有形状的图像保存到本地磁盘中。 请帮助我使用地图图像上的处理程序拖动形状(jpeg 格式)。

【问题讨论】:

    标签: asp.net image jpeg shape drag


    【解决方案1】:

    我可以告诉你如何添加基本处理程序来绘制和拖动你的形状。 我希望你一定在使用

    using System.Drawing;
    

    代码可能是这样的:

    Rectangle rec = new Rectangle(0, 0, 0, 0);
    
    protected override void OnMouseDown(MouseEventArgs e) {
      if (e.Button == MouseButtons.Left) {
        rec = new Rectangle(e.X, e.Y, 0, 0);      
      }
    }
    protected override void OnMouseMove(MouseEventArgs e) {
      if (e.Button == MouseButtons.Left) {
        rec.Width = e.X - rec.X;
        rec.Height = e.Y - rec.Y;
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-07
      • 1970-01-01
      • 1970-01-01
      • 2021-03-21
      • 2021-08-10
      相关资源
      最近更新 更多