Comparing Pictures

Posted on 2000-05-01
Last Modified: 2008-02-26
Hello there!
Say I have two picture boxes, Picture1 and Picture2 and I want to compare the content of them. Is there a way for me to find out if the content is equal in the two picture boxes?

Question by:martinag
  • 2
  • 2

Accepted Solution

Ruchi earned 100 total points
ID: 2766808

"The code can flip pictures, invert them using 3 different methods, compare pictures, divides the Picture into its three main channels and it combines them to one"
LVL 28

Expert Comment

ID: 2766905
assuming the two pictures are the same scale then you can do this:

function compare()
for i = 0 to picture1.scalewidth
   for j = o t0 picture1.scaleheight
      color1 = picture1.point(i,j)
      color2 = picture2.point(i,j)
      if color1 <> color2 then
         msgbox "not equal"
         exit function
      end if
msgbox "equal"
end function

Author Comment

ID: 2767002
Thanks both of you. Seems stupid not to have an API-call for this task. Anyway, the points go to the first poster - sorry AzraSound . . .


Expert Comment

ID: 2767005
From the link I posted, I pulled some code. The following code is simliar to ArazSound's code.

Place a command button on the form.

Private Sub Command1_Click()
Dim s As Boolean

sw = Picture1(0).ScaleWidth
sh = Picture1(0).ScaleHeight

s = True
For i = 0 To sw
For j = 0 To sh
    col1 = Picture1(0).Point(i, j)
    col2 = Picture1(4).Point(i, j)
    If col1 <> col2 Then
        s = False
        GoTo endw
    End If
Next j
Next i
If s Then
MsgBox "OK"
MsgBox "Net OK"
End If
End Sub
LVL 28

Expert Comment

ID: 2767018
there may be api to do it, though i've never worked with it before. you can get the entire color table from a dib so i suppose there is a way to compare those color tables once you extract them from the two respective pictures.

if youre interested, check out info at msdn regarding:


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now