c#如何获取鼠标在picturebox上的点的颜色?
PrivateSubPicture7_MouseMove(ButtonAsInteger,ShiftAsInteger,xAsSingle,yAsSingle)IfPic...
Private Sub Picture7_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Picture7.Point(x, y) = ComPara.Command7.BackColor Then
Shape7.Move x - Val(X4.Text) / 500, y + Val(Y4.Text) / 20
Shape7.Visible = True
Shape7.BorderColor = ComPara.Command7.BackColor
Picture7.ToolTipText = "X:" & Format$(x, "0.0") & "," & "Y:" & Format$(y, "0.0")
Exit Sub
Else
Shape7.Visible = False
End If
End Sub
------------------
这个是vb中的代码,当鼠标在picturebox上移动时,如果遇到了某种特定的颜色,就用一个圈圈标出来
这个在c#中如何实现? 展开
If Picture7.Point(x, y) = ComPara.Command7.BackColor Then
Shape7.Move x - Val(X4.Text) / 500, y + Val(Y4.Text) / 20
Shape7.Visible = True
Shape7.BorderColor = ComPara.Command7.BackColor
Picture7.ToolTipText = "X:" & Format$(x, "0.0") & "," & "Y:" & Format$(y, "0.0")
Exit Sub
Else
Shape7.Visible = False
End If
End Sub
------------------
这个是vb中的代码,当鼠标在picturebox上移动时,如果遇到了某种特定的颜色,就用一个圈圈标出来
这个在c#中如何实现? 展开
1个回答
展开全部
使用DrawToBitmap把PictureBox转换为一个Bitmap,然后在通过GetPixel方法得到某一个点的颜色
Bitmap picBackGround = new Bitmap(this.pictureBox.Width, this.pictureBox.Height);
this.pictureBox.DrawToBitmap(picBackGround, new Rectangle(0, 0, this.pictureBox.Width, this.pictureBox.Height));
某一点的坐标x,y的颜色
Color currentColor = picBackGround.GetPixel(x,y);
Bitmap picBackGround = new Bitmap(this.pictureBox.Width, this.pictureBox.Height);
this.pictureBox.DrawToBitmap(picBackGround, new Rectangle(0, 0, this.pictureBox.Width, this.pictureBox.Height));
某一点的坐标x,y的颜色
Color currentColor = picBackGround.GetPixel(x,y);
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询