UDF > GDIPlus > Image >


_GDIPlus_DrawImageFXEx

Dessine une partie d'une image après l'application d'un effet spécifié

#include <GDIPlus.au3>
_GDIPlus_DrawImageFXEx ( $hGraphics, $hImage, $hEffect [, $nX = 0 [, $nY = 0 [, $nW = 0 [, $nH = 0 [, $hMatrix = 0 [, $hImgAttributes = 0 [, $iUnit = 2]]]]]]] )

Paramètres

$hGraphics Handle de l'objet Graphics.
$hImage Handle de l'objet Image.
$hEffect Handle de l'objet Effect qui est appliqué à l'image avant le rendu. L'image n'est pas modifiée de façon permanente par l'effet.
$nX [optionnel] Coordonnée X du coin supérieur gauche de la partie de l'image à dessiner.
$nY [optionnel] Coordonnée Y du coin supérieur gauche de la partie de l'image à dessiner.
$nW [optionnel] Largeur du rectangle de la partie de l'image à dessiner.
$nH [optionnel] Hauteur du rectangle de la partie de l'image à dessiner.
$hMatrix [optionnel] Handle de l'objet Matrix qui spécifie le parallélogramme dans lequel la partie de l'image est rendue.
$hImgAttributes [optionnel] Handle de l'objet ImageAttributes qui spécifie les réglages de couleur à appliquer lorsque l'image est rendue.
$iUnit [optionnel] Spécifie l'unité de mesure pour l'image.

Valeur de retour

Succès: Retourne True.
Échec: Retourne False et définit @error <> 0, @extended contient le code erreur ($GPID_ERR*).
@error: -1 - GDIPlus.dll ne supporte pas cette fonction.
10 - Paramètres invalides.

En relation

_GDIPlus_DrawImageFX, _GDIPlus_EffectCreate

Exemple

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

_Example()

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

    If Not _GDIPlus_Startup() Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)

    Local $iWidth = 600
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage) * 600 / _GDIPlus_ImageGetWidth($hImage)

    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", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    Local $hEffect = _GDIPlus_EffectCreate($GDIP_HueSaturationLightnessEffectGuid)
    Local $tEffectParameters = DllStructCreate($tagGDIP_EFFECTPARAMS_HueSaturationLightness)

    Local $fW, $fH
    For $i = 1 To 140
        DllStructSetData($tEffectParameters, "HueLevel", Random(-180, 180, 1))
        _GDIPlus_EffectSetParameters($hEffect, $tEffectParameters)
        $fW = Random(20, 100)
        $fH = Random(20, 100)
        _GDIPlus_DrawImageFXEx($hGraphics, $hBitmap, $hEffect, Random(0, $iWidth - $fW), Random(0, $iHeight - $fH), $fW, $fH)
    Next

    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