Function Reference


_GDIPlus_ImageAttributesCreate

Creates an ImageAttributes object

#include <GDIPlus.au3>
_GDIPlus_ImageAttributesCreate ( )

Return Value

Success: a pointer to a new ImageAttribute object.
Failure: 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPIP_ERR* see GPIPlusConstants.au3).

Remarks

After you are done with the object, call _GDIPlus_ImageAttributesDispose() to release the object resources.

Related

_GDIPlus_ImageAttributesDispose

See Also

Search GdipCreateImageAttributes in MSDN Library.

Example

#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

        ;create the color matrix used to adjust the colors of the image
        Local $tColorMatrix = _GDIPlus_ColorMatrixCreateTranslate(0.25, .33, 0.5) ;use translation color matrix to change the image brightness

        _GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $tColorMatrix) ;adjust the ImageAttribute color-key color matrix

        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