Visual Basic Picture Compareing

I was thinking of doing prebased pictures, and then compare them for true / false values. So for example I give vb the coords to grab the image from the screen, so like x,y " Top Left ", and x,y " Bottom Left. It would then generate a picture in a png format maby, and then it could compare a stored png for any differences? I found a link on youtube that seems to do picutre compare can someone help me automate it so it don't have to ask user for the pictures. Is there away to store the pictures inside of the vb program so they are not floating on the local drive, or do they have to be outside of the program. Thanks.

Can this be automated?
LVL 1
Jack_JonesAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
Yes, it is possible to embed images in the app itself.

How big are the images?  For small images, you can compare pixel by pixel and return a true/false.  This is a slow operation and not very practical for large images.

It can be automated by polling with a Timer control.

*Again, only if we are talking small images!
0
Jack_JonesAuthor Commented:
250kb - 600kb max image size
0
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
What is the resolution?

For example: 125x40 pixels
0
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

Jack_JonesAuthor Commented:
min would be 40 x 40, up to 150 x 150
0
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
K...so the embedded pictures should be BITMAPS.

Click on Project --> Add Existing Item --> Select the Bitmap.
In Solution Explorer, select the newly added Bitmap.
In the Properties Pane, change the Build Action to Embedded Resource.
You can access the embedded resource using code like this:

    Dim AlarmClock As New Bitmap(Me.GetType, "AlarmClock.bmp")

Note that this is one of the few cases in VB.Net where the string names are CASE SENSITIVE.  The "AlarmClock.bmp" must match exactly as it is listed in Solution Explorer.

Now, to compare a piece of the screen to the embedded bitmap you use Graphics.CopyFromScreen() as before but use a bigger area.  Then you use two nested for loops to compare the pixels and drop out immediately if any don't match:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim AlarmClock As New Bitmap(Me.GetType, "Alarmclock.BMP")
        If IsImageAt(New Point(100, 75), AlarmClock) Then

        Else

        End If
    End Sub

    Private Function IsImageAt(ByVal pt As Point, ByVal embeddedBMP As Bitmap) As Boolean
        Dim bmp As New Bitmap(embeddedBMP.Size.Width, embeddedBMP.Size.Height)
        Using G As Graphics = Graphics.FromImage(bmp)
            G.CopyFromScreen(pt, New Point(0, 0), embeddedBMP.Size)
        End Using
        For x As Integer = 0 To embeddedBMP.Size.Width - 1
            For y As Integer = 0 To embeddedBMP.Size.Height - 1
                If Not embeddedBMP.GetPixel(x, y).Equals(bmp.GetPixel(x, y)) Then
                    Return False
                End If
            Next
        Next
        Return True
    End Function

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jack_JonesAuthor Commented:
Tested and working great, thanks for your help all day lol. You rock!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.