Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to change Brightness  ????

Posted on 2005-04-10
12
Medium Priority
?
1,256 Views
Last Modified: 2008-01-09
Hi

How can I change the brightness of the screen / window application ??
I have tried using the SetColorAdjustment function but nothing happend when I chenged the caBrightness parameterof the tagCOLORADJUSTMENT.

This is what i did :

procedure TForm1.Button1Click(Sender: TObject);
var
  hw : HWND;                
  nc : tagCOLORADJUSTMENT;

begin
  //I first got the normal  tagCOLORADJUSTMENT of the form :
  hw := Form1.Handle;
  GetColorAdjustment(GetDeviceContext(hw),nc);


  //and then I try to change it and set it back:
  nc.caBrightness := 50;
  nc.caIlluminantIndex := ILLUMINANT_B;
  SetColorAdjustment(GetDeviceContext(hw),nc);  
  Refresh;

end;

what can I do to make it work ??

Is there other functions to use ??

Thanks
0
Comment
Question by:nirdu
  • 5
  • 3
  • 2
  • +2
12 Comments
 
LVL 11

Expert Comment

by:shaneholmes
ID: 13747234
You can not do this. Monitors are not programmable.

You can do a certain amount of this within a display driver by adjusting
the colors in the hardware palette, but there's no way for an application
to do so on a system-wide basis.

You see this done in Games - HOW? It  is changed in the image shown, not in the hardware settings. So you could change your program's colours to make it appear brighter or darker.  


Now if its an image in your app - you could do this. There are many examples  (do a google search) for changing brightness / contrast of images.

Sorry!

sholmes
0
 

Author Comment

by:nirdu
ID: 13747637
I want to change the whole window brightnes / contrast / colors. Not just the imeges inside it, but also the menues, captions, buttons, status bars, and so on ... !!!

Is changing the palette is the answer for it ?
If it is how can I change a palette ?
How can I couse this change to affect all the project windows (should I change a pallet for each form seperate) ?
0
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 13749295
shaneholmes, as far as I know, it is possible to adjust monitor's settings by using DirectX.

nirdu, about changing brightness for a single app - can't you just use brighter backgrounds, fonts etc?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Expert Comment

by:IElite
ID: 13749315
ZhaawZ,

right - exactly - and as far as i know, it is determined by hardware/ monitor drivers... and is found more in a graphics type environment (GAMES), etc.

However, im listening......... i've been known to be wrong many times.......

Shane
0
 
LVL 16

Accepted Solution

by:
CodedK earned 300 total points
ID: 13749534
Hi..

Some video cards allows you to programmingly modify the Gamma Ramp values.
You can use this feature to change the brightness of the entire screen...By using the Gamma Ramp API.

Follow this link for full source code :
http://www.nirsoft.net/vc/change_screen_brightness.html

:)

Delphi souce:
http://homepages.borland.com/efg2lab/Library/UseNet/2002/0914.txt

Hope this helps...
CodedK
0
 

Author Comment

by:nirdu
ID: 13770587
Codedk

Thanks for your delphi code example its working great.
(-:

I used that code and changed the line :
V := Round(255 * Power(I / 255, Abs(Value) / 255));  //only for brighter screen
to :
V := Round(255 * power(I / 255, 1/(Abs(Value) / 255)));  //only for darker screen

That way I can make the screen darker.

But for now the darknes and brightnes is very limited.
What can I change in that code so I can make the screen more darker / brighter then it can be ??
0
 
LVL 16

Expert Comment

by:CodedK
ID: 13770720
Didnt check it but what happens if you revert the fraction...
0
 

Author Comment

by:nirdu
ID: 13770736

I have noticed one more thing about that delphi code u gave me.
When I change the brightnes the white color stays the same (it never changes to darker white or brighter white).
I tried to change the white color manually in the SetGamma function by adding the line :
if V = 0 then V := 50;
after the calculation of V.
But still the white color stay the same.

Whay is that ? How can I change it ?
0
 
LVL 16

Expert Comment

by:CodedK
ID: 13770771
Cant check it right now unfortunately... :/
0
 
LVL 16

Expert Comment

by:CodedK
ID: 13770777
If v=0 ?? Are u sure V=0 ?
0
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 14535718
 procedure ChangeGammaRamp;
  var
    n, c, cr, cg, cb : integer;
    ramp : array [0..2] of array [0..255] of word;
  begin
  // cr, cg and cb are -128 .. +128
  cr := 50;
  cg := 60;
  cb := 70;
  for n := 0 to 255 do begin  
    c := (n + cr) shl 8; if c > $ffff then c := $ffff else if c < 0 then c := 0; ramp[0, n] := c;
    c := (n + cg) shl 8; if c > $ffff then c := $ffff else if c < 0 then c := 0; ramp[1, n] := c;
    c := (n + cb) shl 8; if c > $ffff then c := $ffff else if c < 0 then c := 0; ramp[2, n] := c;
  end;
  SetDeviceGammaRamp(dc, ramp);
  end;
0
 
LVL 16

Expert Comment

by:CodedK
ID: 14537484
Thanks
:/
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This is an update to some code that someone else posted on Experts Exchange. It is an alternate approach, I think a little easier to use, & makes sure that things like the Task Bar will update.
Integration Management Part 2
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question