日期:2014-05-18  浏览次数:20728 次

如何使用画刷编辑一个bmp图?
画刷选择一种颜色。鼠标按下后移动,在bmp图片上画图。


------解决方案--------------------
涉及到GDI, 
主要是取到鼠标在drawing 区域 所留下的痕迹
------解决方案--------------------
呵呵,跟以前大学里的C++作业好像啊

在panel上画图的话,这样就行
C# code

    Point srcPoint;
    private void panel1_MouseMove(object sender, MouseEventArgs e)
    {
      if ((e.Button & MouseButtons.Left) == MouseButtons.Left)
      {
        if (srcPoint.IsEmpty)
        {
          srcPoint = e.Location;
        }

        Point desPoint = e.Location;

        Control ctl = sender as Control;

        if (ctl != null)
        {
          Pen pen = new Pen(Brushes.Black, 2.0F);
          using (Graphics g = ctl.CreateGraphics())
          {
            g.DrawLine(pen, srcPoint, desPoint);
          }

        }

        srcPoint = desPoint;
      }
    }