Results 1 to 2 of 2

Thread: Problem with code

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    116

    Problem with code

    I am making a program that will identify similar images and if images are similar it will put them in a new picture box. Then it will identify the coordinates of one pixel that is differen tand give it's coordinates. I broke my program down into a few different parts and all of them work but when i put them together it doess not work. here is an example of code that works by itself, but not with in the whole program
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim x As Long, y As Long
    3. Dim c As Long, d As Long
    4. Dim p1 As Long, p2 As Long
    5. Dim R1 As Long, B1 As Long, G1 As Long
    6. Dim R2 As Long, B2 As Long, G2 As Long
    7. Dim t As Long, r As Integer
    8. Dim per As Long, msg As String
    9.  
    10. t = 20
    11.  
    12. Picture1.ScaleMode = 3
    13. Picture2.ScaleMode = 3
    14.  
    15.  
    16. If Picture1.ScaleHeight = 160 And Picture1.ScaleWidth = 160 Then
    17.  
    18. Picture2.Picture = Image1
    19.  
    20.  
    21. Do Until y > Picture1.ScaleHeight Or y > Picture2.ScaleHeight
    22.  
    23. p1 = Picture1.Point(x, y)
    24. p2 = Picture2.Point(x, y)
    25.  
    26. RGB_get p1, R1, B1, G1
    27. RGB_get p2, R2, B2, G2
    28.  
    29. Diff r, R1, R2, B1, B2, G1, G2, t
    30. If r = 0 Then
    31. d = d + 1
    32.  
    33. Else
    34.  
    35. End If
    36. c = c + 1
    37. x = x + 15
    38. If x > Picture1.ScaleWidth Or x > Picture2.ScaleWidth Then x = 0: y = y + 15
    39. Loop
    40.  
    41. per = 100 - ((d / c) * 100)
    42.  
    43. If per > 75 Then
    44. Picture3.Picture = Image1
    45. Else
    46. Picture3.Picture = Image2
    47. End If
    48. End If
    49.  
    50. If Picture1.ScaleHeight = 160 And Picture1.ScaleWidth = 200 Then
    51.  
    52. Picture2.Picture = Image8
    53.  
    54. Do Until y > Picture1.ScaleHeight Or y > Picture2.ScaleHeight
    55.  
    56. p1 = Picture1.Point(x, y)
    57. p2 = Picture2.Point(x, y)
    58.  
    59. RGB_get p1, R1, B1, G1
    60. RGB_get p2, R2, B2, G2
    61.  
    62. Diff r, R1, R2, B1, B2, G1, G2, t
    63. If r = 0 Then
    64. d = d + 1
    65.  
    66. Else
    67.  
    68. End If
    69. c = c + 1
    70. x = x + 15
    71. If x > Picture1.ScaleWidth Or x > Picture2.ScaleWidth Then x = 0: y = y + 15
    72. Loop
    73.  
    74. per = 100 - ((d / c) * 100)
    75.  
    76. If per > 75 Then
    77. Picture3.Picture = Image8
    78. Else
    79. Picture3.Picture = Image7
    80. End If
    81. End If
    82.  
    83. End Sub


    i attached the source of the program. i know the pictures look weird, but i'm making the program for my little 7 year old brother to help him in some online game he plays. thanks for any help
    Attached Files Attached Files

  2. #2
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    Re: Problem with code

    the project tells me it is missing rgb.bas (I assume that is your pixel color comparison function(s))
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width