Advertisement
tic

Gdip_CompareImage

tic
Mar 25th, 2013
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Gdip_CompareImage(Bitmap1, Bitmap2, ByRef x, ByRef y)
  2. {
  3.     static _CompareImage
  4.     if !_CompareImage
  5.     {
  6.         MCode_CompareImage := "8B442414995383E2035503C233DB56C1F802395C241C577E458B7C24188B74241C03C003C0894424248DA4240000000033C98"
  7.         . "5F67E1B8B5424142B5424188BC78B2C023B28753383C10183C0043BCE7CEF037C242483C3013B5C24207CD28B4C24288B54242C5F5E5DC701FFFFFFFF"
  8.         . "C702FFFFFFFF83C8FF5BC38B5424288B44242C5F5E890A89185D33C05BC3"
  9.  
  10.         VarSetCapacity(_CompareImage, StrLen(MCode_CompareImage)//2)
  11.         Loop % StrLen(MCode_CompareImage)//2      ;%
  12.             NumPut("0x" SubStr(MCode_CompareImage, (2*A_Index)-1, 2), _CompareImage, A_Index-1, "char")
  13.            
  14.         DllCall("VirtualProtect", "ptr", &_CompareImage, "ptr", VarSetCapacity(_CompareImage), "uint", 0x40, "ptrA", 0)
  15.     }
  16.  
  17.     Gdip_GetImageDimensions(Bitmap1, width1, height1), Gdip_GetImageDimensions(Bitmap2, width2, height2)
  18.    
  19.     if (width1 != width2 || height1 != height2)
  20.         return -1
  21.  
  22.     E1 := Gdip_LockBits(Bitmap1, 0, 0, width1, height1, Stride1, Scan01, BitmapData1)
  23.     E2 := Gdip_LockBits(Bitmap2, 0, 0, width2, height2, Stride2, Scan02, BitmapData2)
  24.     if (E1 || E2)
  25.         return -2
  26.  
  27.     x := y := 0
  28.     E := DllCall(&_CompareImage, "ptr", Scan01, "ptr", Scan02, "int", width1, "int", height1, "int", Stride1, "int*", x, "int*", y)
  29.  
  30.    Gdip_UnlockBits(Bitmap1, BitmapData1), Gdip_UnlockBits(Bitmap2, BitmapData2)
  31.    return (E = "") ? -3 : E
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement