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