# RedEyeCorrection class
{: .no_toc }

An [**Effect**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Effect.md) that corrects red eyes in the rectangles of a picture that a program names.

The effect works only inside the rectangles of its [**RedEyeCorrectionParams**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Types/RedEyeCorrectionParams.md). The program, or the user, finds the eyes; the effect fixes their colour. The class mirrors the GDI+ [RedEyeCorrection](https://learn.microsoft.com/en-us/windows/win32/api/gdipluseffects/nl-gdipluseffects-redeyecorrection) class and inherits the members of [**Effect**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Effect.md).

* TOC
{:toc}

## Creating

Syntax: *fx* **= RedEyeCorrection**( )

Syntax: *fx* **= RedEyeCorrection**( *params* )

Each form is also available as **New RedEyeCorrection**( ... ) with the same arguments.

*params*
: *required* A [**RedEyeCorrectionParams**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Types/RedEyeCorrectionParams.md): the number of areas and the memory that holds their rectangles.

A constructor that fails creates an unusable object whose **LastResult** tells why.

The effect created without arguments has no areas, and [**Bitmap.ApplyEffect**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Bitmap.md#applyeffect) refuses to apply it: the call returns 2 (**InvalidParameter**).

> [!WARNING] 0.9.45.0
> In a 64-bit program the form with *params* stops the program with an access violation. A 32-bit program is not affected. To work in both, create the effect without arguments and set [**Parameters**](#parameters), which works in both.

## Parameters

Syntax: *fx*.**Parameters** [ **=** *params* ]

Syntax: *params* **=** *fx*.**Parameters**( *size* )

Gets or sets the [**RedEyeCorrectionParams**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Types/RedEyeCorrectionParams.md). The setter creates the GDI+ effect again and sets the parameters on the new one, with the size `LenB(Of RedEyeCorrectionParams)` plus the size of the rectangles.

> [!WARNING] 0.9.45.0
> The getter returns zeros and sets **LastResult** to 2 (**InvalidParameter**) unless it is given *size*. On an effect that has areas it does so even with *size*, so the areas cannot be read back: keep the **RedEyeCorrectionParams** that was set. See [**Effect**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Effect.md#parameters).

The areas are described by a structure whose methods allocate and fill the rectangles; the page of [**RedEyeCorrectionParams**](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Types/RedEyeCorrectionParams.md) shows them.

```tb check_build check_run
Dim user As GdiPlusUser = GdiPlusUser()

Dim fx As RedEyeCorrection = RedEyeCorrection()
Debug.Print fx.LastResult

Dim bmp As Bitmap = Bitmap(10!, 10!)
Graphics(bmp).Clear(Color(255, 220, 20, 20))
Debug.Print bmp.ApplyEffect(fx, GpRect(0, 0, 10, 10))
' Output:
' 0
' 2
```

## See Also

- [RedEyeCorrection](https://learn.microsoft.com/en-us/windows/win32/api/gdipluseffects/nl-gdipluseffects-redeyecorrection) -- Microsoft's documentation of the GDI+ class
- [Effect](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Effect.md) class
- [RedEyeCorrectionParams](/twinBASIC-docs/tB/Packages/Contributed/GdiPlus/Types/RedEyeCorrectionParams.md) type
