Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GDIPlus.au3>
- #include <WinApi.au3>
- #include <GDIP.au3>
- Opt("GUIOnEventMode", 1)
- Global $nWidth = 640, $nHeight = 480
- $hWnd = GUICreate("Ersetzer", $nWidth, $nHeight)
- GUISetOnEvent(-3, "_Exit", $hWnd)
- GUISetState()
- $hDC = _WinAPI_GetDC($hWnd)
- $hDC_Buffer = _WinAPI_CreateCompatibleDC($hDC)
- $hGDI_Bitmap = _WinAPI_CreateCompatibleBitmap($hDC, $nWidth, $nHeight)
- _WinAPI_SelectObject($hDC_Buffer, $hGDI_Bitmap)
- _GDIPlus_Startup()
- $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC_Buffer)
- $hBitmap_Img = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\IMG_1018.JPG")
- $hBitmap_BG = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\new_bg.jpg")
- _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap_Img, 0, 0, $nWidth, $nHeight)
- _WinAPI_BitBlt($hDC, 0, 0, $nWidth, $nHeight, $hDC_Buffer, 0, 0, 0x00CC0020)
- $hBitmap_Img = _ReplacePixel($hBitmap_Img, $hBitmap_BG, 0xFCFDF7, 40)
- MsgBox(0, "Fertig", "Fertig")
- While Sleep(40)
- _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap_Img, 0, 0, $nWidth, $nHeight)
- _WinAPI_BitBlt($hDC, 0, 0, $nWidth, $nHeight, $hDC_Buffer, 0, 0, 0x00CC0020)
- WEnd
- Func _ReplacePixel($img, $bg, $color, $tol = 0)
- $width = _GDIPlus_ImageGetWidth($img)
- $height = _GDIPlus_ImageGetHeight($img)
- $graphic = _GDIPlus_ImageGetGraphicsContext($img)
- For $x = 0 To 10
- For $y = 0 To $height
- $pixel = Hex(_GDIPlus_BitmapGetPixel($img, $x, $y), 6)
- $temp_pixel = Hex(_GDIPlus_BitmapGetPixel($bg, $x, $y), 6)
- ;; R, G, B Toleranz
- If BinaryMid($pixel, 1, 1) <= Number(BinaryMid($color, 1, 1)) + 5 And BinaryMid($pixel, 1, 1) >= Number(BinaryMid($color, 1, 1)) - 5 And _
- BinaryMid($pixel, 2, 1) <= Number(BinaryMid($color, 2, 1)) + 5 And BinaryMid($pixel, 2, 1) >= Number(BinaryMid($color, 2, 1)) - 5 And _
- BinaryMid($pixel, 3, 1) <= Number(BinaryMid($color, 3, 1)) + 5 And BinaryMid($pixel, 3, 1) >= Number(BinaryMid($color, 3, 1)) - 5 Then
- MsgBox (0, "", "")
- $brush = _GDIPlus_BrushCreateSolid("0xFF" & $temp_pixel)
- _GDIPlus_GraphicsFillRect($graphic, $x, $y, 1, 1, $brush)
- _GDIPlus_BrushDispose($brush)
- EndIf
- Next
- Next
- _GDIPlus_BitmapDispose($graphic)
- Return ($img)
- EndFunc ;==>_ReplacePixel
- Func _Exit()
- _WinAPI_ReleaseDC($hWnd, $hDC)
- _WinAPI_DeleteDC($hDC_Buffer)
- _WinAPI_DeleteObject($hGDI_Bitmap)
- _GDIPlus_ImageDispose($hBitmap_Img)
- _GDIPlus_ImageDispose($hBitmap_BG)
- _GDIPlus_GraphicsDispose($hGraphics)
- _GDIPlus_Shutdown()
- Exit
- EndFunc ;==>_Exit
Add Comment
Please, Sign In to add comment