1

私は若い「プログラマー」で、400 x 500 の画像 (私のコンピューターの bmp ファイル) が画面に表示されるかどうかを検索するコードを作成しようとしています。

コードは次のようになります。

パブリック クラス Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    'Dim-ing section'
    Dim scrsize As Size = New Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
    Dim scrtake = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
    Dim path As String = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory, "fishbot.bmp")
    Dim resource As New Bitmap(path)

    Dim a As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(scrtake)
    Dim b As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(resource)

    a.CopyFromScreen(New Point(0, 0), New Point(0, 0), scrsize)



   'as a test to see if the code is compiled until here'
    Me.BackgroundImage = scrtake 
   'end test'

    For x As Integer = 100 To scrsize.Height - 400
        For y As Integer = 300 To scrsize.Width - 300
            For x1 As Integer = 0 To resource.Height
                For y1 As Integer = 0 To resource.Width
                    If scrtake.GetPixel(x, y) = resource.GetPixel(x1, y1) Then
                        TextBox1.Text = "found"

                    End If
                Next
            Next
        Next
    Next







End Sub

また、要素はすでにフォーム上にあります。

 For x As Integer = 100 To scrsize.Height - 400
            For y As Integer = 300 To scrsize.Width - 300
                For x1 As Integer = 0 To resource.Height
                    For y1 As Integer = 0 To resource.Width
                    If scrtake.GetPixel(x, y) = resource.GetPixel(x1, y1) Then
                        TextBox1.Text = "found"

                    End If
                Next
            Next
        Next
    Next

このコードは次を返します:「パラメーターは正で < 高さである必要があります。パラメーター名: y」と解決策が見つかりません。また、多くのサイトをチェックしましたが、まだ何もありません。ピクセルのより良い比較システムまたは速度を向上させる何かを知っている場合は、私と共有してください:)。

4

1 に答える 1