I need to overlap two images. When overlapped at the correct point, the overlapped portion of both images match exactly (or very closely).

Now, I have tried to match the color of each pixel in the images, then move one image a bit and match them again until I get a high match rate, usually 95% or higher. The issue is, this is ridiculously slow. Also, I can't find a way to check the pixels if one I need to check a negative co-ordinate.

Here is what I have tried. It's totally wrong, but I have been poking at it for days.

Code:
        For y As Int32 = 0 To bmp2.Height Step 4
            If y + StartPos.Y >= bmp1.Height Then Exit For
            For x As Int32 = 0 To bmp2.Width Step 4
                If x + StartPos.X >= bmp1.Width Then Exit For
                C1 = bmp1.GetPixel(x + StartPos.X, y + StartPos.Y)
                C2 = bmp2.GetPixel(x, y)

                If C1 = C2 Then match += 1
            Next
        Next