相机画框绘画事件 [英] Camera picturebox paint event
问题描述
我创建了一个应用程序,其中在PictureBox上显示了带DirectX的实时摄像机.我要在图片框的中心放置交叉线.
I have created application in which I displayed live camera with directX on PictureBox. I want Cross lines on center of picturebox.
如果我断开连接,则可以看到摄像头线&;油漆事件起火.但是当我连接相机&我获得了现场展示绘画活动不触发&如果事件引发,则不会显示行.
If i disconnects camera lines are visible & paint event fires. But when I connect camera & I gets live display paint event doesn't fire & if the event raise it doesn't display lines.
公共子PictureBox1_Paint(作为对象发送,作为PaintEventArgs发送)处理PictureBox1.Paint
Xp = PictureBox1.Width
Yp = PictureBox1.Height
Xc = Xp/2
Yc = Yp/2
midpointX = Xc
中点Y = Yc
昏暗的objPen作为笔
将objPicGraphics变暗为图形= e.Graphics
objPen =新笔(clr,thk)
objPen.DashStyle = Drawing2D.DashStyle.Solid
objPicGraphics.DrawLine(objPen,0,midpointY,Xp,midpointY)
objPicGraphics.DrawLine(objPen,midpointX,0,midpointX,Yp)
Public Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint
Xp = PictureBox1.Width
Yp = PictureBox1.Height
Xc = Xp / 2
Yc = Yp / 2
midpointX = Xc
midpointY = Yc
Dim objPen As Pen
Dim objPicGraphics As Graphics = e.Graphics
objPen = New Pen(clr, thk)
objPen.DashStyle = Drawing2D.DashStyle.Solid
objPicGraphics.DrawLine(objPen, 0, midpointY, Xp, midpointY)
objPicGraphics.DrawLine(objPen, midpointX, 0, midpointX, Yp)
结束子
推荐答案
我要在图片框的中心放置交叉线.
I want Cross lines on center of picturebox.
我认为您更有可能希望在图片框上显示的图像上出现交叉线.您应该显示将图片显示到图片框的代码,因为这是您绘制交叉线的地方.
I think it is more likely that you want crossed lines on the image that you are displaying on the picturebox. You should show the code that displays the image to the picturebox, because that's where you need to draw your crossed lines.
这篇关于相机画框绘画事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!