Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6362525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:55:09+00:00 2026-05-24T23:55:09+00:00

I am looking into modifying brightness/contrast/gamma of my display i found an api whose

  • 0

I am looking into modifying brightness/contrast/gamma of my display i found an api whose purpose i think is this but i didn’t had much success implementing it… here is the code

var
i,j:Integer;
buf:array [0..2,0..255] of Word;
wBright:Word;
myDC:HDC;
begin
    myDC:=GetDc(GetDesktopWindow);
    GetDeviceGammaRamp(mydc,buf);

   for i:=0 to 2 do
      for j:=0 to 255 do
        begin
            buf[i][j]:=buf[i][j] + 100; //if i don't modify the values the api works
        end;
    SetDeviceGammaRamp(mydc,buf);
end;

I will be grateful if you point me into right direction. Thanks.

The last error says : The parameter is incorrect

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:55:10+00:00Added an answer on May 24, 2026 at 11:55 pm

    The values in the array must really be a ramp, i.e. they map the possible R, G and B values to a brightness value. This way you can create funny effects too, but not with the routine below. Found something like this on the web:

    uses Windows;
    
    //    SetDisplayBrightness
    //
    //    Changes the brightness of the entire screen.
    //    This function may not work properly in some video cards.
    //
    //    The Brightness parameter has the following meaning:
    //
    //      128       = normal brightness
    //      above 128 = brighter
    //      below 128 = darker
    
    function SetDisplayBrightness(Brightness: Byte): Boolean;
    var
      GammaDC: HDC;
      GammaArray: array[0..2, 0..255] of Word;
      I, Value: Integer;
    begin
      Result := False;
      GammaDC := GetDC(0);
    
      if GammaDC <> 0 then
      begin
        for I := 0 to 255 do
        begin
          Value := I * (Brightness + 128);
          if Value > 65535 then
            Value := 65535;
          GammaArray[0, I] := Value; // R value of I is mapped to brightness of Value
          GammaArray[1, I] := Value; // G value of I is mapped to brightness of Value
          GammaArray[2, I] := Value; // B value of I is mapped to brightness of Value
        end;
    
        // Note: BOOL will be converted to Boolean here.
        Result := SetDeviceGammaRamp(GammaDC, GammaArray); 
    
        ReleaseDC(0, GammaDC);
      end;  
    end;
    

    Unfortunately, in my Win7 VM in Parallels on a Mac, I can’t test his, but it should work on most normal Windows PCs.

    Edit

    FWIW, I ran it in my Win7 VM and the routine returns True. If I use other values, e.g.

    Value := 127 * I;
    

    the routine returns False and

    ShowMessage(SysErrorMessage(GetLastError));
    

    displays

    The parameter is incorrect

    Changing this to:

    Value := 128 * I;
    

    returns True again. I assume the values must form some kind of slope (or ramp). This routine creates a linear ramp. I guess you can also use other kinds, e.g. a sigmoid, to achieve other effects, like higher contrast.

    I can’t, of course, see any differences in brightness in the VM, sorry.

    Update: But it seems to work for David Heffernan and I could just test it on my sister in law’s laptop, and there it works too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking into Kohana documentation, i found this really usefull function that they use to
By looking into the Open JPA website i've found that i can log the
Am looking into developing an iPhone native app using Titanium Developer Since this is
I looking into making a kind of robot testing browser. Like Selenium, but one
I've been looking into OSGi recently and think it looks like a really good
Looking into selector performance between $('#ID1, #ID2, #ID3') vs $('1X CLASS'). Which is faster?
Currently looking into learn new technology and silverlight is on the potential list. However,
I am looking into a friend's site which is really old and strange, and
I have been looking into benchmarking lately, I have always been interested in logging
I've been looking into Authorization with AspNetWebApi and information is a little sparse on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.