Function Reference


_GDIPlus_DrawImageFX

Draws a portion of an image after applying a specified effect

#include <GDIPlus.au3>
_GDIPlus_DrawImageFX ( $hGraphics, $hImage, $hEffect [, $tRECTF = 0 [, $hMatrix = 0 [, $hImgAttributes = 0 [, $iUnit = 2]]]] )

Parameters

$hGraphics Handle to a Graphics object.
$hImage Handle to an Image object.
$hEffect Handle to an Effect that is applied to the image before rendering. The image is not permanently altered by the effect.
$tRECTF [optional] $tagGDIPRECTF structure that specifies the portion of the image to be drawn.
$hMatrix [optional] Handle to a Matrix object that specifies the parallelogram in which the image portion is rendered.
$hImgAttributes [optional] Handle to an ImageAttributes object that specifies color adjustments to be applied when the image is rendered.
$iUnit [optional] Specifies the unit of measure for the image.

Return Value

Success: True.
Failure: False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPIP_ERR* see GPIPlusConstants.au3).
@error: -1 - GDIPlus.dll does not support this function.
10 - Invalid parameters.

Related

$tagGDIPRECTF, _GDIPlus_DrawImageFXEx, _GDIPlus_EffectCreate

See Also

Search GdipDrawImageFX in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
        If Not _GDIPlus_Startup() Or @extended < 6 Then
                MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
                Return
        EndIf

        Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
        If @error Or Not FileExists($sFile) Then Return

        Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)
        Local $iImgW = _GDIPlus_ImageGetWidth($hImage)
        Local $iImgH = _GDIPlus_ImageGetHeight($hImage)

        Local $iWidth = 600
        Local $iHeight = $iImgH * 600 / $iImgW

        Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)
        Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
        _GDIPlus_GraphicsDrawImageRect($hContext, $hImage, 0, 0, $iWidth, $iHeight)

        Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
        Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
        GUISetState(@SW_SHOW)

        _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)

        Local $hEffect = _GDIPlus_EffectCreateHueSaturationLightness(-90)
        Local $tRECTF = _GDIPlus_RectFCreate($iWidth * 0.25, $iHeight * 0.25, $iWidth * 0.5, $iHeight * 0.5)
        _GDIPlus_DrawImageFX($hGraphics, $hBitmap, $hEffect, $tRECTF)

        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE

        _GDIPlus_GraphicsDispose($hContext)
        _GDIPlus_BitmapDispose($hBitmap)
        _GDIPlus_EffectDispose($hEffect)
        _GDIPlus_ImageDispose($hImage)
        _GDIPlus_GraphicsDispose($hGraphics)
        _GDIPlus_Shutdown()
EndFunc   ;==>_Example