tarunlalwani
Member
- Joined
- Oct 14, 2007
- Messages
- 7
- Programming Experience
- Beginner
I am trying to XOR two images to find there differences using BtiBlt. But the image i get is a blank one.
I am not sure why is this happening. Can anyone provide some insight on this?
I am not sure why is this happening. Can anyone provide some insight on this?
VB.NET:
Private Sub XORImages(ByVal Src1 As String, ByVal Src2 As String)
Dim oImage1 As Bitmap = Bitmap.FromFile(Src1)
Dim oImage2 As Bitmap = Bitmap.FromFile(Src2)
Dim oGfxImage1 As Graphics = Graphics.FromImage(oImage1)
Dim oGfxImage2 As Graphics = Graphics.FromImage(oImage2)
Dim oMixedImage As Bitmap = New Bitmap(oImage1.Width, oImage1.Height, oGfxImage1)
Dim oGfxMixedImage As Graphics = Graphics.FromImage(oMixedImage)
Dim hdcDest As IntPtr = oGfxMixedImage.GetHdc
Dim hdcSrc1 As IntPtr = oGfxImage1.GetHdc
Dim hdcSrc2 As IntPtr = oGfxImage2.GetHdc
BitBlt(hdcDest, 0, 0, oMixedImage.Width, oMixedImage.Height, hdcSrc1, 0, 0, SRCCOPY)
BitBlt(hdcDest, 0, 0, oMixedImage.Width, oMixedImage.Height, hdcSrc2, 0, 0, SRCINVERT)
oGfxImage1.ReleaseHdc()
oGfxImage2.ReleaseHdc()
oGfxMixedImage.ReleaseHdc()
oGfxMixedImage.Flush()
oGfxMixedImage.Dispose()
oGfxMixedImage = Nothing
oGfxImage1.Dispose()
oGfxImage1 = Nothing
oGfxImage2.Dispose()
oGfxImage2 = Nothing
oMixedImage.Save("C:\mixed.jpg")
oMixedImage.Dispose()
oMixedImage = Nothing
End Sub