# Function Reference

# _GDIPlus_EffectCreateRedEyeCorrection

Creates a RedEyeCorrection class effect object

#include <GDIPlus.au3>
_GDIPlus_EffectCreateRedEyeCorrection ( $aAreas )

## Parameters

$aAreas | An array of areas of the bitmap to which red eye correction should be applied: [0][0] - Number of Area rectangles [1][0] - X coordinate of the upper-left corner of the first rectangle [1][1] - Y coordinate of the upper-left corner of the first rectangle [1][2] - Width of the first rectangle [1][3] - Height of the first rectangle ... [n][0] - X coordinate of the upper-left corner of the nth rectangle [n][1] - Y coordinate of the upper-left corner of the nth rectangle [n][2] - Width of the nth rectangle [n][3] - Height of the nth rectangle

## Return Value

Success: | a handle to an Effect object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GDIP_ERR* see GPIPlusConstants.au3).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameters.

## Remarks

When you are done with the Effect object, call _GDIPlus_EffectDispose() to release the resources.

## Related

_GDIPlus_EffectCreate, _GDIPlus_EffectDispose

## 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 $hBitmap = _GDIPlus_BitmapCreateFromMemory(_RedEye())

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

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

        Local $aAreas[3][4] = [[2]]
        $aAreas[1][0] = 50
        $aAreas[1][1] = 64
        $aAreas[1][2] = 22
        $aAreas[1][3] = 18

        $aAreas[2][0] = 155
        $aAreas[2][1] = 64
        $aAreas[2][2] = 21
        $aAreas[2][3] = 18

        Local $hEffect = _GDIPlus_EffectCreateRedEyeCorrection($aAreas)
        Local $hBitmap_FX = _GDIPlus_BitmapCreateApplyEffect($hBitmap, $hEffect)

        Local $iTimer = TimerInit(), $iStep = 0
        Do
            If TimerDiff($iTimer) > 400 Then
                Switch Mod($iStep, 2)
                    Case 0
                        _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight)
                    Case Else
                        _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap_FX, 0, 0, $iWidth, $iHeight)
                EndSwitch
                $iStep += 1
                $iTimer = TimerInit()
            EndIf
        Until GUIGetMsg() = $GUI_EVENT_CLOSE

        _GDIPlus_EffectDispose($hEffect)
        _GDIPlus_ImageDispose($hBitmap_FX)
        _GDIPlus_ImageDispose($hBitmap)
        _GDIPlus_GraphicsDispose($hGraphics)
        _GDIPlus_Shutdown()
    EndFunc   ;==>_Example

    ; Code below was generated by: 'File to Base64 String' Code Generator v1.11 Build 2012-10-13
    Func _RedEye($bSaveBinary = False)
        Local $sRedEye
        $sRedEye &= ' '
        $sRedEye &= ' '
        $sRedEye &= ' '
        $sRedEye &= ' '
        $sRedEye &= ' '
        Local $dBinary = Binary(_Base64Decode($sRedEye))
        If $bSaveBinary Then
            Local $hFile = FileOpen(@ScriptDir & "\220px-BoldRedEye.JPG", 18)
            FileWrite($hFile, $dBinary)
            FileClose($hFile)
        EndIf
        Return $dBinary
    EndFunc   ;==>_RedEye

    Func _Base64Decode($sB64String)
        Local $tStruct = DllStructCreate("int")
        Local $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", "str", $sB64String, "int", 0, "int", 1, "ptr", 0, "struct*", $tStruct, "ptr", 0, "ptr", 0)
        If @error Or Not $a_Call[0] Then Return SetError(1, 0, "")
        Local $tA = DllStructCreate("byte[" & DllStructGetData($tStruct, 1) & "]")
        $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", "str", $sB64String, "int", 0, "int", 1, "struct*", $tA, "struct*", $tStruct, "ptr", 0, "ptr", 0)
        If @error Or Not $a_Call[0] Then Return SetError(2, 0, "")
        Return DllStructGetData($tA, 1)
    EndFunc   ;==>_Base64Decode