|I started working a much more detailed description of how to play with the curve but realized that isn't what you were confused about.
Gamma-correcting an image is essentially raising its color intensities to 1/gamma, so that when the monitor in turn raises the value to gamma, these cancel out.
You said ... I'm trying to work the problem backwards from the GetDeviceGammaRamp function call to whatever input values would be required to create the current gamma ramp array. You need to explain why you want to reverse it .. you aren't a hardware device. Your code is designed for something like a game where it simply loads a slight adjustment to the colors at start up where it will set the gamma ramp table on the DC. You sound more like you are trying to do something like an ICC profile.
Your code is a basic exponential function it wouldn't really match a real monitor gamma output distortion which would need something like a spline. That would all be done in a processing phase not down on the output out to a device context. So I think you need to explain more what you are trying to do.
Perhaps read the Microsoft overview of gamma control on windows and expand it from there.
Using gamma correction (Windows)[^]
The current gamma correction occurs on 1 line of code in your example above
value = (Math.Pow(value / 65535, 1 / gamma) * 65535) + 0.5;
The initial gamma is divided by 10 so if you enter 10 you get Math.Pow(value / 65535, 1) that is it's linear
and the value is basically value/65535*65535 .. AKA the same value.
Value is defined as
double value = i * 256;
So all that whole function does is return a value in 256 step increments.
With gamma set to 10 you are going to get 0,255,511, ... 65535
The reverse table can be built using the line
value = (Math.Pow(value / 65535, gamma) * 65535) + 0.5;
Straight mathematics anything raised to a power is inverted by raising to 1/power so replace 1/gamma with gamma, I made bold and underlined so the substitution is more obvious.
Still confused what you are trying to do, but hopefully something there helps.
In vino veritas
modified 5-Sep-16 6:26am.