Crée et initialise une matrice couleur niveaux de gris
#include <GDIPlus.au3>
_GDIPlus_ColorMatrixCreateGrayScale ( )
Une matrice couleur 'niveaux de gris' transforme une couleur quelconque en un niveau de gris caractérisé par le même pourcentage de rouge, vert, bleu. Les coefficients d'une telle matrice sont adaptés à la sensibilité de l'oeil humain, voici un exemple:
Consultez ColorMatrix dans la Librairie MSDN.
#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <ScreenCapture.au3> #include <WinAPIHObj.au3> Example() Func Example() _GDIPlus_Startup() ; Initialise GDI+ Local Const $iWidth = 600, $iHeight = 600 Local $hGUI = GUICreate("GDI+ example", $iWidth, $iHeight) ; Crée une GUI de test GUISetState(@SW_SHOW) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ; Crée un objet graphique à partir du handle de la fenêtre Local $hIA = _GDIPlus_ImageAttributesCreate() ; Crée un objet ImageAttribute Local $tColorMatrix = _GDIPlus_ColorMatrixCreateGrayScale() ; Crée une matrice couleur niveaux de gris _GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $tColorMatrix) ; Définit la matrice couleur niveaux de gris Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iWidth, $iHeight) ; Crée un bitmap GDI en capturant une zone du bureau Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ; Convertit le bitmap GDI en GDI+ _WinAPI_DeleteObject($hHBmp) ; Libére la ressource bitmap GDI car n'est plus nécessaire _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, $hIA) ; Dessine le bitmap tout en appliquant le changement des couleurs Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Nettoie les ressources GDI+ _GDIPlus_ImageAttributesDispose($hIA) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() GUIDelete($hGUI) EndFunc ;==>Example