Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleCalculate the XOR of two images
DescriptionThis example shows how to calculate the XOR of two images in Visual Basic.
KeywordsXOR, image, PaintPicture, image processing
CategoriesGraphics
 
Taking the XOR of two images shows where the images differ. The result is black where the images are the same and not black elsewhere.

This is quite simple in Visual Basic 6. The program simply copies one image into a result PictureBox and then uses PaintPicture to copy the second image on top while specifying the vbSrcInvert opcode.

 
Private Sub cmdGo_Click()
    ' Copy the first picture into the result.
    picResult.Picture = Picture1.Picture

    ' Copy the second picture on in XOR mode.
    picResult.PaintPicture Picture2.Picture, 0, 0, _
        OpCode:=vbSrcInvert
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated