Click here to Skip to main content
6,594,932 members and growing! (17,204 online)
Email Password   helpLost your password?
Languages » C# » Applications     Intermediate

Gammit! An easy to use application for desktop gamma correction

By Gladstone

It's a simple application to save the gamma correction level and reset the saved value with only one click. Values are stored in the registry. Some options are available as well.
C#.NET 2.0, Win2K, WinXPVS2005, Dev
Posted:21 Jul 2006
Views:17,074
Bookmarked:19 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
6 votes for this article.
Popularity: 3.41 Rating: 4.38 out of 5
1 vote, 16.7%
1

2

3
1 vote, 16.7%
4
4 votes, 66.7%
5

Gammit! Dialog Shot

Introduction

I own an LCD monitor, and the default CRT gamma level makes it too bright for me. For various reasons, some application or situation can set the gamma level of my monitor to this value, ignoring my settings, and each time I must open Catalyst (which needs time to start, and consumes a huge quantity of memory) to readjust the settings. So I decided to find something to save my gamma correction level and which would let me restore the saved value with only a click (on the taskbar area would be perfect). Searching on CodeProject for some solution took me to this article: Gamma correction slider by Dany Cantin. Yes, it did the work but not as I wanted. First, I tried to edit the code, but then I found that a from-0 solution would be easier. So I did it.

The Code

I made the application in .NET 2.0, using C#. It was very easy and fast, and the program did its dirty work well. As you can see, in the code, I re-used the Dany routine to calculate the SetGammaRamp argument, starting from the gamma level. I know it isn't a long or hard code, but I've used it because it works and so it would be stupid to rewrite it and waste time.

For seting the value..

for (int i = 0; i < 256; i++)
{
    ramp[i] = ramp[i + 256] = ramp[i + 512] =
    (UInt16)Math.Min(65535, Math.Max(0, 
            Math.Pow((float)((i + 1) / 256.0), 
            (float)Gamma) * 65535 + 0.5));
}

and to get it:

float[] rgb = { 1.0f, 1.0f, 1.0f };

for (int i = 0; i < 3; i++)
{
    float Csum = 0.0f;
    int Ccount = 0;
    int min = 256 * i;
    int max = min + 256;

    for (int j = min; j < max; j++)
    {
        if (j != 0 && _RampSaved[j] != 0)
        {
            double B = (j % 256) / 256.0;
            double A = _RampSaved[j] / 65536.0;
            float C = (float)(Math.Log(A) / Math.Log(B));

            Csum += C;
            Ccount++;
        }
    }

    rgb[i] = Csum / Ccount;
}
return rgb[0];

Conclusions

So, that's all, I think. I hope you'll find it useful, bye!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Gladstone


Member

Location: Italy Italy

Other popular C# articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 1 of 1 (Total in Forum: 1) (Refresh)FirstPrevNext
GeneralDual Monitors Pinmembersrboisvert3:56 27 Jul '06  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 21 Jul 2006
Editor: Smitha Vijayan
Copyright 2006 by Gladstone
Everything else Copyright © CodeProject, 1999-2009
Web15 | Advertise on the Code Project