Guest User

Untitled

a guest
Jul 31st, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.45 KB | None | 0 0
  1. #include <GDIPlus.au3>
  2. #include <WinApi.au3>
  3. #include <GDIP.au3>
  4.  
  5. Opt("GUIOnEventMode", 1)
  6.  
  7. Global $nWidth = 640, $nHeight = 480
  8.  
  9. $hWnd = GUICreate("Ersetzer", $nWidth, $nHeight)
  10. GUISetOnEvent(-3, "_Exit", $hWnd)
  11. GUISetState()
  12.  
  13. $hDC = _WinAPI_GetDC($hWnd)
  14. $hDC_Buffer = _WinAPI_CreateCompatibleDC($hDC)
  15. $hGDI_Bitmap = _WinAPI_CreateCompatibleBitmap($hDC, $nWidth, $nHeight)
  16. _WinAPI_SelectObject($hDC_Buffer, $hGDI_Bitmap)
  17.  
  18. _GDIPlus_Startup()
  19. $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC_Buffer)
  20.  
  21. $hBitmap_Img = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\IMG_1018.JPG")
  22. $hBitmap_BG = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\new_bg.jpg")
  23.  
  24. _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap_Img, 0, 0, $nWidth, $nHeight)
  25. _WinAPI_BitBlt($hDC, 0, 0, $nWidth, $nHeight, $hDC_Buffer, 0, 0, 0x00CC0020)
  26.  
  27. $hBitmap_Img = _ReplacePixel($hBitmap_Img, $hBitmap_BG, 0xFCFDF7, 40)
  28.  
  29. MsgBox(0, "Fertig", "Fertig")
  30.  
  31. While Sleep(40)
  32.     _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap_Img, 0, 0, $nWidth, $nHeight)
  33.  
  34.  
  35.     _WinAPI_BitBlt($hDC, 0, 0, $nWidth, $nHeight, $hDC_Buffer, 0, 0, 0x00CC0020)
  36. WEnd
  37.  
  38. Func _ReplacePixel($img, $bg, $color, $tol = 0)
  39.     $width = _GDIPlus_ImageGetWidth($img)
  40.     $height = _GDIPlus_ImageGetHeight($img)
  41.  
  42.     $graphic = _GDIPlus_ImageGetGraphicsContext($img)
  43.  
  44.     For $x = 0 To 10
  45.         For $y = 0 To $height
  46.             $pixel = Hex(_GDIPlus_BitmapGetPixel($img, $x, $y), 6)
  47.             $temp_pixel = Hex(_GDIPlus_BitmapGetPixel($bg, $x, $y), 6)
  48.             ;; R, G, B Toleranz
  49.                  If BinaryMid($pixel, 1, 1) <= Number(BinaryMid($color, 1, 1)) + 5 And BinaryMid($pixel, 1, 1) >= Number(BinaryMid($color, 1, 1)) - 5 And _
  50.                     BinaryMid($pixel, 2, 1) <= Number(BinaryMid($color, 2, 1)) + 5 And BinaryMid($pixel, 2, 1) >= Number(BinaryMid($color, 2, 1)) - 5 And _
  51.                     BinaryMid($pixel, 3, 1) <= Number(BinaryMid($color, 3, 1)) + 5 And BinaryMid($pixel, 3, 1) >= Number(BinaryMid($color, 3, 1)) - 5 Then
  52.                 MsgBox (0, "", "")
  53.                 $brush = _GDIPlus_BrushCreateSolid("0xFF" & $temp_pixel)
  54.                 _GDIPlus_GraphicsFillRect($graphic, $x, $y, 1, 1, $brush)
  55.                 _GDIPlus_BrushDispose($brush)
  56.             EndIf
  57.         Next
  58.     Next
  59.     _GDIPlus_BitmapDispose($graphic)
  60.     Return ($img)
  61. EndFunc   ;==>_ReplacePixel
  62.  
  63. Func _Exit()
  64.     _WinAPI_ReleaseDC($hWnd, $hDC)
  65.     _WinAPI_DeleteDC($hDC_Buffer)
  66.     _WinAPI_DeleteObject($hGDI_Bitmap)
  67.  
  68.     _GDIPlus_ImageDispose($hBitmap_Img)
  69.     _GDIPlus_ImageDispose($hBitmap_BG)
  70.  
  71.     _GDIPlus_GraphicsDispose($hGraphics)
  72.     _GDIPlus_Shutdown()
  73.     Exit
  74. EndFunc   ;==>_Exit
Add Comment
Please, Sign In to add comment