2017-11-22 24 views
0

これをコーディングする場合:ビットマップ画像、gr.drawRectangleはマウス移動イベントvb.net中

Sub PcbOriginalMouseMove(sender As Object, e As MouseEventArgs) 
     Try 
      If isSelecting = True Then 
       x1 = e.X 
       y1 = e.Y 
       Dim bm As New Bitmap(pcbOriginal.Image) 

       Using gr As Graphics = Graphics.FromImage(bm) 
        gr.DrawRectangle(Pens.Red, Math.Min(x0,x1), Math.Min (y0,y1), Math.Abs(x0-x1), Math.Abs(y0-y1)) 
       End Using 

       pcbOriginal.Image = bm 
      End If 
     Catch ex As Exception 
     End Try 
End Sub 

I持っ繰り返し矩形PICに見られる(マウス移動が選択された領域):

マウス素早く移動:

drawn rectangle when moving the mouse quickly

マウスはゆっくり移動:

drawn rectangle when moving the mouse slowly

+0

あなたの質問は何ですか?あなたはどんな結果を期待していますか? – Detonar

+0

私はこの問題を編集して改善しようとしましたが、見ました...あなたは質問さえしませんでした。 – Clijsters

+0

ああ、申し訳ありません!あなたは絶対に正しい...私の質問は? –

答えて

0

これが動作している方法である。

 If isSelecting = True Then 

      x1 = e.X 
      y1 = e.Y 

      originalImage = Image.FromFile("D:\Imagenes\Logos\Logo-Tecnicos-para-Chile.jpg") 

      Dim bm As New Bitmap (originalImage) 

      Using gr As Graphics = Graphics.FromImage(bm) 

       gr.DrawRectangle(Pens.Red, Math.Min(x0,x1), Math.Min (y0,y1), Math.Abs(x0-x1), Math.Abs(y0-y1)) 

      End Using 

      originalImage = bm 
      pcbOriginal.Image = originalImage 
     End If 

    Catch ex As Exception 
    End Try[enter image description here][1] 

に結果を試してください:ユーザーが別のpicboxに示されているPIC領域を選択する[1]:https://i.stack.imgur.com/ihLXg.png

関連する問題