Hello Patrick,
the code below should give you the values (I have tested it quickly), but they are calculated only in a linear way. Possibly you can change the algorithm to fit your need use non-linear functions.
function GetGammaValue(scrPos, scrMin, scrCenter, scrMax: integer):double;
begin
if scrPos = scrCenter then
result := 1.00
else if scrPos < scrCenter then
result := 1.00 + (8.00 - 1.00) * (1 - (scrPos - scrMin) / (scrCenter - scrMin)) //gives 8 for position = min
else
result := 0.01 + (1.00 - 0.01) * (1 - (scrPos - scrCenter) / (scrMax - scrCenter)); //gives 0.01 for position = max
end;
I use 8 as value for minimum position, and 0.01 for max position, as you have requested.
Example of use:
ShowMessage(FloatToStr(GetGammaValue(1, 1, 100, 200)));
ShowMessage(FloatToStr(GetGammaValue(100, 1, 100, 200)));
ShowMessage(FloatToStr(GetGammaValue(200, 1, 100, 200)));
ShowMessage(FloatToStr(GetGammaValue(25, 1, 100, 200)));
ShowMessage(FloatToStr(GetGammaValue(50, 1, 100, 200)));
ShowMessage(FloatToStr(GetGammaValue(125, 1, 100, 200)));
ShowMessage(FloatToStr(GetGammaValue(150, 1, 100, 200)));
ShowMessage(FloatToStr(GetGammaValue(175, 1, 100, 200)));
Francesco Savastano
Nwscomps.com
Add-ons for the ImageEn Library