Für Effekte solltest du mal nach Colormatrix googlen
Hier ein Beispielscript:
Spoiler anzeigen
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
Opt("TrayIconDebug",1)
[/autoit] [autoit][/autoit] [autoit]$sFile = FileOpenDialog("Wähle Bilddatei",@ScriptDir,"(*.jpg;*.bmp;*.png;*.gif)")
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile($sFile)
$iH = _GDIPlus_ImageGetHeight($hImage)*96/_GDIPlus_ImageGetHorizontalResolution($hImage)
$iW = _GDIPlus_ImageGetWidth($hImage)*96/_GDIPlus_ImageGetVerticalResolution($hImage)
$hGui = GUICreate("Test", $iW, $iH)
GUISetState()
$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
$hBitmap=_GDIPlus_BitmapCreateFromGraphics($iW, $iH,$hGraphics)
$hContext=_GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsDrawImage($hContext, $hImage, 0, 0)
GUIRegisterMsg($WM_ERASEBKGND, "_WM_ERASEBKGND")
_WinAPI_RedrawWindow($hGui,0,0,5)
MsgBox(0, "", "Original" & @LF & "Drücke Ok")
$hImage1 = _ColorMatrix($hImage,"0.30,0.30,0.30,0,0|0.59,0.59,0.59,0,0|0.11,0.11,0.11,0,0|0,0,0,1,0|0,0,0,0,1")
_GDIPlus_GraphicsDrawImage($hContext, $hImage1, 0, 0)
_WinAPI_RedrawWindow($hGui,0,0,5)
MsgBox(0, "", "Greyscale" & @LF & "Drücke Ok")
_GDIPlus_ImageDispose($hImage1)
$hImage1 = _ColorMatrix($hImage,"-1,0,0,0,0|0,-1,0,0,0|0,0,-1,0,0|0,0,0,1,0|0,0,0,0,1")
_GDIPlus_GraphicsDrawImage($hContext, $hImage1, 0, 0)
_WinAPI_RedrawWindow($hGui,0,0,5)
MsgBox(0, "", "Invert" & @LF & "Drücke Ok")
_GDIPlus_ImageDispose($hImage1)
$hImage1 = _ColorMatrix($hImage,"1,0,0,0,0|0,0,0,0,0|0,0,0,0,0|0,0,0,1,0|0,0,0,0,1")
_GDIPlus_GraphicsDrawImage($hContext, $hImage1, 0, 0)
_WinAPI_RedrawWindow($hGui,0,0,5)
MsgBox(0, "", "Red" & @LF & "Drücke Ok")
_GDIPlus_ImageDispose($hImage1)
$hImage1 = _ColorMatrix($hImage,"0,0,0,0,0|0,1,0,0,0|0,0,0,0,0|0,0,0,1,0|0,0,0,0,1")
_GDIPlus_GraphicsDrawImage($hContext, $hImage1, 0, 0)
_WinAPI_RedrawWindow($hGui,0,0,5)
MsgBox(0, "", "Green" & @LF & "Drücke Ok")
_GDIPlus_ImageDispose($hImage1)
$hImage1 = _ColorMatrix($hImage,"0,0,0,0,0|0,0,0,0,0|0,0,1,0,0|0,0,0,1,0|0,0,0,0,1")
_GDIPlus_GraphicsDrawImage($hContext, $hImage1, 0, 0)
_WinAPI_RedrawWindow($hGui,0,0,5)
MsgBox(0, "", "Blue" & @LF & "Drücke Ok")
_GDIPlus_ImageDispose($hImage1)
$hImage1 = _ColorMatrix($hImage,"1,1,0,0,0|0,0,0,0,0|0,0,0,0,0|0,0,0,1,0|0,0,0,0,1")
_GDIPlus_GraphicsDrawImage($hContext, $hImage1, 0, 0)
_WinAPI_RedrawWindow($hGui,0,0,5)
MsgBox(0, "", "Yellow" & @LF & "Drücke Ok")
_GDIPlus_ImageDispose($hImage1)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_GraphicsDispose($hContext)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_Shutdown()
Func _ColorMatrix($hImage,$sMatrix)
Local $hGraphics=_GDIPlus_ImageGetGraphicsContext($hImage)
Local $iWidth = _GDIPlus_ImageGetWidth($hImage)
Local $iHeight = _GDIPlus_ImageGetHeight($hImage)
Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
_GDIPlus_GraphicsDispose($hGraphics)
Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
Local $tColorMatrix = DllStructCreate("float[5];float[5];float[5];float[5];float[5]")
Local $aMatrix=StringSplit(StringReplace($sMatrix,"|",","),","), $iCnt=0
For $i=1 To 5
For $j=1 To 5
$iCnt+=1
DllStructSetData($tColorMatrix, $i, $aMatrix[$iCnt], $j)
Next
Next
Local $hImgAttrib = _GDIPlus_ImageAttributesCreate()
_GDIPlus_ImageAttributesSetColorMatrix($hImgAttrib, 1, DllStructGetPtr($tColorMatrix))
_GDIPlus_GraphicsDrawImageRectRectEx($hContext, $hImage, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, 2, $hImgAttrib)
_GDIPlus_GraphicsDispose($hContext)
_GDIPlus_ImageAttributesDispose($hImgAttrib)
Return $hBitmap
EndFunc ;==>_GreyScale
Func _WM_ERASEBKGND($hWnd, $iMsg, $wParam, $lParam)
_GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
Return True
EndFunc
Func _GDIPlus_ImageAttributesSetColorMatrix($hImgAttrib, $iColorAdjustType, $pColorMatrix = 0, $pGrayMatrix = 0, $iColorMatrixFlags = 0)
Local $fEnable = 1, $aResult = DllCall($ghGDIPDll, "int", "GdipSetImageAttributesColorMatrix", "ptr", $hImgAttrib, "int", $iColorAdjustType, _
"int", $fEnable, "ptr", $pColorMatrix, "ptr", $pGrayMatrix, "int", $iColorMatrixFlags)
Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc ;==>_GDIPlus_ImageAttributesSetColorMatrix
;;Creates ImageAttributes object
Func _GDIPlus_ImageAttributesCreate()
Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreateImageAttributes", "ptr*", 0)
Return SetError($aResult[0], 0, $aResult[1])
EndFunc ;==>_GDIPlus_ImageAttributesCreate
;;Deletes ImageAttributes object
Func _GDIPlus_ImageAttributesDispose($hImgAttrib)
Local $aResult = DllCall($ghGDIPDll, "int", "GdipDisposeImageAttributes", "ptr", $hImgAttrib)
Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc ;==>_GDIPlus_ImageAttributesDispose
;; _GDIPlus_GraphicsDrawImageRectRectEx()
;; Same as _GDIPlus_GraphicsDrawImageRectRect(), but adds 1 optional parameter - $hImgAttrib (handle to ImageAttributes object)
Func _GDIPlus_GraphicsDrawImageRectRectEx($hGraphics, $hImage, $iSrcX, $iSrcY, $iSrcWidth, $iSrcHeight, $iDstX, $iDstY, $iDstWidth, $iDstHeight, $iUnit = 2, $hImgAttrib = 0)
Local $aResult = DllCall($ghGDIPDll, "int", "GdipDrawImageRectRectI", "hwnd", $hGraphics, "hwnd", $hImage, "int", $iDstX, "int", _
$iDstY, "int", $iDstWidth, "int", $iDstHeight, "int", $iSrcX, "int", $iSrcY, "int", $iSrcWidth, "int", _
$iSrcHeight, "int", $iUnit, "ptr", $hImgAttrib, "int", 0, "int", 0)
Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc ;==>_GDIPlus_GraphicsDrawImageRectRectEx
mfgE