I think I should have perhaps explained the curve part definition. I appreciate it when others comment their equations and code. `lookupTable[i] = (int)(0.5 + switchpointYValue + (255-switchpointYValue) * ( 1.0 - pow( (255-x)/(255-switchpointXValue), endCurvePower) ));`

The curves of y=x^2, y=x^3, y=x^4 ..... (including the non integer numbers inbetween 2, 3, 4, etc) represent curves that start from (0, 0) on the left, and curve upward up to (1.0, 1.0) as they go to the right.

The above code implements that same set of curves, but starting at the top right, and curving increasingly downward as x goes to the left, until it reaches the switchPoint.

The expression (255-x)/255-switchpointXValue) represents how far along (in a fraction between 0 and 1) a point is to the left from the upper right corner on its way left to the switchPoint.

Raising that to a power, curves it upward.

(1.0 minus that) curves it downward.

To get it to meet vertically at the switch point, that result, 0 to 1, is scaled by the amount it has to cover, which is the distance from the top down to the switchPoint.

That factor is (255-switchpointYValue).

Finally, that scaled amount gets added to the switchpointY value, as it represents an amount higher than that Y value.

I don't know if this made it any clearer, but I thought I'd explain my math the way I like others to explain their's!

Cheers!