Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GDIPlus.au3>
- #include <Color.au3>
- ; -Author: name22 (www.autoit.de)
- $iX = 0
- $iY = 0
- $sFile = FileOpenDialog("Bild auswählen", "", "Images (*.jpg;*.bmp;*.png)")
- If @error Then Exit
- _GDIPlus_Startup()
- $hBitmap = _GDIPlus_ImageLoadFromFile($sFile)
- $iColor = 0x01020304; _GDIPlus_GetPixel($hBitmap, $iX, $iY)
- $tARGB = DllStructCreate("BYTE[4]")
- DllStructSetData($tARGB, 1, $iColor)
- $iA = DllStructGetData($tARGB, 1, 4)
- $iR = DllStructGetData($tARGB, 1, 3)
- $iG = DllStructGetData($tARGB, 1, 2)
- $iB = DllStructGetData($tARGB, 1, 1)
- MsgBox(0, "Farbe:", "Alpha: " & @TAB & $iA & @CRLF & "Rot: " & @TAB & $iR & @CRLF & "Grün: " & @TAB & $iG & @CRLF & "Blau: " & @TAB & $iB & @CRLF & @CRLF & "Gesamt: 0x" & Hex($iA, 2) & Hex($iR, 2) & Hex($iG, 2) & Hex($iB, 2))
- _GDIPlus_ImageDispose($hBitmap)
- _GDIPlus_Shutdown()
- Func _GDIPlus_GetPixel($hBitmap, $x, $y)
- ; Prog@ndy
- Local $result = DllCall($ghGDIPDLL, "int", "GdipBitmapGetPixel", "ptr", $hBitmap, "int", $x, "int", $y, "dword*", 0)
- If @error Then Return SetError(1, 0, 0)
- Return SetError($result[0], 1, $result[4])
- EndFunc ;==>_GDIPlus_GetPixel
- Func _GDIPlus_SetPixel($hBitmap, $x, $y, $ARGB)
- ; Prog@ndy
- Local $result = DllCall($ghGDIPDLL, "int", "GdipBitmapSetPixel", "ptr", $hBitmap, "int", $x, "int", $y, "dword", $ARGB)
- If @error Then Return SetError(1, 0, 0)
- Return SetError($result[0], 1, $result[0] = 0)
- EndFunc ;==>_GDIPlus_SetPixel
- Func _ColorGetARGB($iColorARGB)
- ;Author: name22 (www.autoit.de)
- Local $aRet_ARGB[4], $tARGB_Tmp = DllStructCreate("BYTE[4]")
- DllStructSetData($tARGB_Tmp, 1, $iColorARGB)
- $aRet_ARGB[0] = DllStructGetData($tARGB_Tmp, 1, 4) ;Alpha
- $aRet_ARGB[1] = DllStructGetData($tARGB_Tmp, 1, 3) ;Red
- $aRet_ARGB[2] = DllStructGetData($tARGB_Tmp, 1, 2) ;Green
- $aRet_ARGB[3] = DllStructGetData($tARGB_Tmp, 1, 1) ;Blue
- Return $aRet_ARGB
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement