Changing Display gamma [SOLVED]
-
Hi, What should I use to change the display's gamma? I tried looking on google, but I don't see anywhere how to do it. Can you give me a link, or an example of changing the value? I need it to be able to change it when I want and faster, I could go each time in "Display Color Calibration" and change it from there, but that takes time, and I can't add a key shortcut to certain values. Just as a note, I want to change gamma, not brightness.
-
Hi, What should I use to change the display's gamma? I tried looking on google, but I don't see anywhere how to do it. Can you give me a link, or an example of changing the value? I need it to be able to change it when I want and faster, I could go each time in "Display Color Calibration" and change it from there, but that takes time, and I can't add a key shortcut to certain values. Just as a note, I want to change gamma, not brightness.
See Using gamma correction | Microsoft Docs[^] and follow the links to the relevant functions like the SetDeviceGammaRamp function | Microsoft Docs[^].
-
See Using gamma correction | Microsoft Docs[^] and follow the links to the relevant functions like the SetDeviceGammaRamp function | Microsoft Docs[^].
I tried looking at "Windows Graphics Device Interface" and "Microsoft Direct3D 9’s" but without an example to understand, I got lost in the parameters types they ask. I would like to make it kinda like the slider from "Display Color Calibration" (Calibrate Display Color, as you find it in search box), the difference will be that I will add a function so you can add some default key shortcuts to certain gamma values. I'm used to code in Java, but there is no way to change gamma using that.
-
I tried looking at "Windows Graphics Device Interface" and "Microsoft Direct3D 9’s" but without an example to understand, I got lost in the parameters types they ask. I would like to make it kinda like the slider from "Display Color Calibration" (Calibrate Display Color, as you find it in search box), the difference will be that I will add a function so you can add some default key shortcuts to certain gamma values. I'm used to code in Java, but there is no way to change gamma using that.
You have to generate a table that is passed to the setter function. That is what the calibration does too: It generates the table according to the slider position. But I do't know the formula (and the range used by the calibration tool). If you only need a few selections, you can use the getter function to read the table for different calibration settings.
-
You have to generate a table that is passed to the setter function. That is what the calibration does too: It generates the table according to the slider position. But I do't know the formula (and the range used by the calibration tool). If you only need a few selections, you can use the getter function to read the table for different calibration settings.
I found the following code in a post, and this note but I didn't figured out what is the min and the max value the float factor should have. Is this the formula you were talking about?
Quote:
To change gamma, cycle into ramp buffer and change RGB color where Gamma is the float factor.
WORD ramp[256*3];
for( int i=0; i<256; i++ ) {
ramp[i+0] = ramp[i+256] = ramp[i+512] =
(WORD)min(65535, max(0, pow((i+1) / 256.0, Gamma) * 65535 + 0.5));
}
SetDeviceGammaRamp(::GetDC(NULL), ramp);I got it from this article (it does contain the source code, but the GUI code is very different from JavaFX): Gamma correction slider[^]
-
I found the following code in a post, and this note but I didn't figured out what is the min and the max value the float factor should have. Is this the formula you were talking about?
Quote:
To change gamma, cycle into ramp buffer and change RGB color where Gamma is the float factor.
WORD ramp[256*3];
for( int i=0; i<256; i++ ) {
ramp[i+0] = ramp[i+256] = ramp[i+512] =
(WORD)min(65535, max(0, pow((i+1) / 256.0, Gamma) * 65535 + 0.5));
}
SetDeviceGammaRamp(::GetDC(NULL), ramp);I got it from this article (it does contain the source code, but the GUI code is very different from JavaFX): Gamma correction slider[^]
Looks good, but I have not tested it. But you do know that this is the C/C++ board and Java would be off topic? However, all you have to do is converting the Algorithm to Java (should be no problem), check how to call Windows API functions from Java, and create the GUI according to your requirements. The GUI from that article is an example. Even a C++ developer using that code would create his own GUI controls and windows instead of using those from the example.
-
Looks good, but I have not tested it. But you do know that this is the C/C++ board and Java would be off topic? However, all you have to do is converting the Algorithm to Java (should be no problem), check how to call Windows API functions from Java, and create the GUI according to your requirements. The GUI from that article is an example. Even a C++ developer using that code would create his own GUI controls and windows instead of using those from the example.
Quote:
But you do know that this is the C/C++ board and Java would be off topic?
Yeah I know, that is why I didn't asked questions about java. I only made a comparison between the 2 of them.
Quote:
However, all you have to do is converting the Algorithm to Java
I know how to use native functions. I missed this part in that article "float factor between 0.0 and 2.0" Thanks for your help.
-
Looks good, but I have not tested it. But you do know that this is the C/C++ board and Java would be off topic? However, all you have to do is converting the Algorithm to Java (should be no problem), check how to call Windows API functions from Java, and create the GUI according to your requirements. The GUI from that article is an example. Even a C++ developer using that code would create his own GUI controls and windows instead of using those from the example.
So, I did a few tests with that formula for set gamma, and I found out that the range 0.0-2.0 isn't actually good. I gave values between 0.0-0.2 and nothing happened, then I tried some values between 0.3-4.0 and it was working. So there are values OVER 2.0 that are working and the values under 0.3 aren't working at all. Can it be that the formula isn't actually correct or that the range he gave is wrong? Or maybe he thought that those values are what users may want?
-
So, I did a few tests with that formula for set gamma, and I found out that the range 0.0-2.0 isn't actually good. I gave values between 0.0-0.2 and nothing happened, then I tried some values between 0.3-4.0 and it was working. So there are values OVER 2.0 that are working and the values under 0.3 aren't working at all. Can it be that the formula isn't actually correct or that the range he gave is wrong? Or maybe he thought that those values are what users may want?
I suggest to read about Gamma correction - Wikipedia[^] to understand it. Note also that the default value for Windows is 2.2. Anything far away from that will display weird. Very low values will simply result in most - if not all - table values to be set to zero. Similar for very high values which will result in 0xFFFF. That means that there is a range of useful Gamma values while all others will be clipped (note the
max()
andmin()
calls in the formula). -
I suggest to read about Gamma correction - Wikipedia[^] to understand it. Note also that the default value for Windows is 2.2. Anything far away from that will display weird. Very low values will simply result in most - if not all - table values to be set to zero. Similar for very high values which will result in 0xFFFF. That means that there is a range of useful Gamma values while all others will be clipped (note the
max()
andmin()
calls in the formula).Thanks for you help!