Sets or clears the color- and grayscale-adjustment matrices for a specified category
#include <GDIPlus.au3>
_GDIPlus_ImageAttributesSetColorMatrix ( $hImageAttributes [, $iColorAdjustType = 0 [, $bEnable = False [, $tClrMatrix = 0 [, $tGrayMatrix = 0 [, $iColorMatrixFlags = 0]]]]] )
$hImageAttributes | Pointer to an ImageAttribute object |
$iColorAdjustType | [optional] The category for which the color- and grayscale-adjustment matrices are set or cleared: 0 - Color or grayscale adjustment applies to all categories that do not have adjustment settings of their own 1 - Color or grayscale adjustment applies to bitmapped images 2 - Color or grayscale adjustment applies to brush operations in metafiles 3 - Color or grayscale adjustment applies to pen operations in metafiles 4 - Color or grayscale adjustment applies to text drawn in metafiles |
$bEnable | [optional] If True, the specified matrices (color, grayscale or both) adjustments for the specified |
$tClrMatrix | [optional] $tagGDIPCOLORMATRIX structure that specifies a color-adjustment matrix |
$tGrayMatrix | [optional] $tagGDIPCOLORMATRIX structure that specifies a grayscale-adjustment matrix |
$iColorMatrixFlags | [optional] Type of image and color that will be affected by the adjustment matrices: 0 - All color values (including grays) are adjusted by the same color-adjustment matrix 1 - Colors are adjusted but gray shades are not adjusted. 2 - Colors are adjusted by one matrix and gray shades are adjusted by another matrix |
Success: | True. |
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPIP_ERR* see GPIPlusConstants.au3). |
$tagGDIPCOLORMATRIX, _GDIPlus_ColorMatrixCreate, _GDIPlus_ColorMatrixCreateGrayScale
Search GdipSetImageAttributesColorMatrix in MSDN Library.
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WinAPIHObj.au3>
Example()
Func Example()
_GDIPlus_Startup() ;initialize GDI+
Local Const $iWidth = 600, $iHeight = 600
Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
GUISetState(@SW_SHOW)
Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
Local $hIA = _GDIPlus_ImageAttributesCreate() ;create an ImageAttribute object
Local $tColorMatrix = _GDIPlus_ColorMatrixCreateTranslate(0.5, 0.5, 0.5) ;create the brightness color matrix
_GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $tColorMatrix) ;adjust the image brightness to be 50% brighter
Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iWidth, $iHeight) ;create a GDI bitmap by capturing an area on desktop
Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap
_WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore
_GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, $hIA) ;draw the bitmap while applying the color adjustment
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
;cleanup GDI+ resources
_GDIPlus_ImageAttributesDispose($hIA)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_Shutdown()
GUIDelete($hGUI)
EndFunc ;==>Example