Drawing Vb.Net:在picturebox中并排动态创建矩形

Drawing Vb.Net:在picturebox中并排动态创建矩形,drawing,rectangles,Drawing,Rectangles,我目前正在开发一个应用程序,在该应用程序中,我使用视频流事件处理程序在VB.Net中的Forms picturebox中生成相机图像(是的,它听起来像kinect应用程序…它是…) 我可以使用以下代码在位图图像(摄影机流)上创建一个红色矩形: Dim g As Graphics = Graphics.FromImage(kinectVideoBitMap) Dim rect As Rectangle = New Rectangle

我目前正在开发一个应用程序,在该应用程序中,我使用视频流事件处理程序在VB.Net中的Forms picturebox中生成相机图像(是的,它听起来像kinect应用程序…它是…)

我可以使用以下代码在位图图像(摄影机流)上创建一个红色矩形:

        Dim g As Graphics = Graphics.FromImage(kinectVideoBitMap)

                Dim rect As Rectangle = New Rectangle
                rect.Width = 6.4
                rect.Height = 480
                g.DrawRectangle(Pens.Red, rect)


        End If
直截了当

但是,我真正想做的是能够在“6.4”处创建多个并排跨越图片框宽度的矩形(
            Dim g As Graphics = Graphics.FromImage(kinectVideoBitMap)
            Dim i As Integer
            For i = 0 To 100
                Dim rect As Rectangle = New Rectangle
                rect.Width = 6.4
                rect.Height = 480
                rect.Location = New System.Drawing.Point(*{not sure how to measure here}*, *{or here either}*)
                g.DrawRectangle(Pens.Red, rect)

            Next
            Dim g As Graphics = Graphics.FromImage(kinectVideoBitMap)
            Dim i As Integer = 1
            Dim newLocationX As Integer = 0

            Do Until i = 100
                Dim rect(i) As Rectangle
                Rect(i) = New Rectangle
                Rect(i).Width = 6
                Rect(i).Height = 480
                Rect(i).Location = New System.Drawing.Point(video.Left + newLocationX, Rect(i).Location.Y)
                g.DrawRectangle(Pens.Red, Rect(i))
                newLocationX = newLocationX + 6
                i += 1
            Loop
        End If
            Dim g As Graphics = Graphics.FromImage(kinectVideoBitMap)
            Dim i As Integer = 0
            Dim newLocationX As Integer = 0

            Do Until i = 640
                Dim rect(i) As Rectangle
                rect(i) = New Rectangle
                rect(i).Width = 6.4
                rect(i).Height = 480
                rect(i).Location = New System.Drawing.Point(video.Right - newLocationX, rect(i).Location.Y)
                g.DrawRectangle(Pens.Red, rect(i))
                newLocationX = newLocationX + 6.4
                i += 1
            Loop