🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Correcting for image brightness on different monitors

Started by
3 comments, last by Anzy 22 years, 7 months ago
Hello, Well, like the subject line indicates, I have found a stumbling block with my game images. Scenes that look great on my system are so dark on some monitors (even with brightness and contrast at max) that important details will be missed. Can someone point me in the right direction to correcting this so that in the final production most people will be able to view the scenes as they were intended. Thanks heaps. Anne
Advertisement
I''ve moved this to the visual forum, as I hope more people here will be familiar with the problem...
I think you need to look into "gamma correction". Most modern games either have a slider control in their options screen that lets you lighten/darken the image, or a key that when pressed keeps lightening the image.

I unfortunately don''t have time to look it up now (I''m on the way out the door) but I''m sure if you look up Gamma correction in google or MSDN you will find some code. I believe DirectX, if that''s what your''re using, has built in functions for it, and maybe OpenGL too for all I know.

Anthracks
Since gamma correction is a platform-specific issue, it is not included in OpenGL. Instead, you use the API of whatever platform you're targetting, probably Win32 in this case.

This code should do the trick.

    // set up an array for the gamma ramps for R, G, and BWORD gamma_ramp[256 * 3];// NOTE: we'll need the device context (HDC) of a window,// usually the main window of your appfor(int i = 0; i < 256; ++i){    // perform the gamma function, scaling the result to    // int([0, 255]); the gamma function is x^(1/gamma), where    // is a value in the range of input values    int g = (int)(255 * (float)pow((i + 0.5) / 255.5, 1.0 / gamma) + 0.5f);    // make sure the calculations yielded proper results    if(g < 0) g = 0;    if(g > 255) g = 255;    // set up the gamma ramps for R, G, and B equally    gamma_ramp[i] = g << 8;              // red ramp    gamma_ramp[256 + i] = gamma_ramp[i]; // green ramp    gamma_ramp[512 + i] = gamma_ramp[i]; // blue ramp}SetDeviceGammaRamp(hdc, gamma_ramp);  


Consider storing the previous gamma ramp using GetDeviceGammaRamp so you can restore it once your app is finished.

Edited by - merlin9x9 on December 2, 2001 2:32:57 PM
Thanks for the help! Much appreciated!!

This topic is closed to new replies.

Advertisement