ColorBalance class

An Effect that shifts the balance between the opposite colours cyan and red, magenta and green, and yellow and blue.

The class mirrors the GDI+ ColorBalance class and inherits the members of Effect.

Creating

Syntax: fx = ColorBalance( )

Syntax: fx = ColorBalance( params )

Syntax: fx = ColorBalance( cyanRed, magentaGreen, yellowBlue )

Each form is also available as New ColorBalance( … ) with the same arguments.

params
required A ColorBalanceParams for the parameters.
cyanRed
required A Long from -100 to 100. A positive value adds red, and a negative one adds cyan.
magentaGreen
required A Long from -100 to 100. A positive value adds green, and a negative one adds magenta.
yellowBlue
required A Long from -100 to 100. A positive value adds blue, and a negative one adds yellow.

A value of 0 changes nothing. A constructor that fails creates an unusable object whose LastResult tells why.

Parameters

Syntax: fx.Parameters [ = params ]

Syntax: params = fx.Parameters( size )

Gets or sets the ColorBalanceParams.

Dim user As GdiPlusUser = GdiPlusUser()

Dim fx As ColorBalance = ColorBalance(10, -20, 30)
Dim p As ColorBalanceParams = fx.Parameters(LenB(Of ColorBalanceParams))
Debug.Print fx.LastResult & " " & p.cyanRed & " " & p.magentaGreen & " " & p.yellowBlue
' Output:
' 0 10 -20 30

Example

The example pushes the colour 200, 100, 50 fully toward red, toward cyan, and toward blue.

Dim user As GdiPlusUser = GdiPlusUser()

Dim red As Bitmap = Bitmap(4!, 4!)
Dim cyan As Bitmap = Bitmap(4!, 4!)
Dim blue As Bitmap = Bitmap(4!, 4!)
Graphics(red).Clear(Color(255, 200, 100, 50))
Graphics(cyan).Clear(Color(255, 200, 100, 50))
Graphics(blue).Clear(Color(255, 200, 100, 50))

red.ApplyEffect ColorBalance(100, 0, 0), GpRect(0, 0, 4, 4)
cyan.ApplyEffect ColorBalance(-100, 0, 0), GpRect(0, 0, 4, 4)
blue.ApplyEffect ColorBalance(0, 0, 100), GpRect(0, 0, 4, 4)
Debug.Print Hex$(red.Pixel(1, 1).argb)
Debug.Print Hex$(cyan.Pixel(1, 1).argb)
Debug.Print Hex$(blue.Pixel(1, 1).argb)
' Output:
' FFFF6432
' FF006432
' FFC86464

See Also