Dim screen on Windows with C++
Asked Answered
G

2

10

I've been looking into dimming a screen on a Windows platform from my program. I know that there's a SetMonitorBrightness API that allows this, but the issue for me is that it would be nice to be able to dim the screen on Windows XP as well (which that API does not support) and also dim screens on desktop computers.

So I did some research and found this utility that seems to dim my screen on a Windows XP desktop without a problem. I tried to contact the author to find out how they implemented the dimmer but I did not hear back from them.

So I was curious to hear from developers on this site, how do you think they managed to dim the screen when the SetMonitorBrightness API is not supported?

PS. I am a newbie developer myself trying to write an energy saving program for our small business. It is a nonprofit organization and we don't have funds to hire a Windows developer to do this for us. Most of our computers are Windows XP desktops, so as you can see I can't use SetMonitorBrightness API as it is widely documented on the web.

Thanks in advance.

Gormley answered 11/8, 2012 at 20:59 Comment(0)
E
4

In the case that you cite, have a look at the screensaver with Dependancy Walker. My guess is that they create a full screen window and use SetLayeredWindowAttributes() to set a semi-opaque setting for the window, thus making the screen appear dimmed. I doubt it would save you much money.

You might want to look into the DDC protocol which allows you to control aspects of some monitors. The MS API that allows you to do this can be found roundabout here: http://msdn.microsoft.com/en-us/library/windows/hardware/ff570290%28v=vs.85%29.aspx and you should look at the I2C functions too.

Alternatively you could look for a ready made library to do the DDC stuff for you, such as http://www.nicomsoft.com/products/i2c/. They too have a dimmer application that is free for personal use and non-free for commercial use. They may even allow you to use it for free if you contact them and explain it's for a non-profit organisation.

If you are trying to do this as an energy saving program why not use a screensaver setting that turns the monitor off after a certain period of idleness? In any case

Empery answered 11/8, 2012 at 21:20 Comment(6)
Thank you for your input. I didn't think about using SetLayeredWindowAttributes() like you described. But wouldn't displaying darker (blacker) pixels require a screen to use less energy?Gormley
To answer your question, why wouldn't I just turn off the monitor, we have a specialized software that outputs data that needs to be visible on the screen, thus I wanted to dim the screen after N minutes of inactivity and then if an operator moves the mouse it would return to 100%.Gormley
@user843732: It might use less energy, but the only way you'd know for sure would be to try it and measure the power consumption. Changing the opacity of a pixel doesn't necessarily change the brightness of the backlight, which is where a lot of the power comes from. Think of a display with the brightness turned up and the blacks appearing grey. A lot of LCD screens only have a single backlight brightness control, some are segmented but few (none?) are on a per pixel basis. As to your application, sounds interesting. Hope you get it working.Empery
Thanks, tinman. Your explanation makes a lot of sense. So you think the only way to save energy is to dim the LCD's backlight, right? PS. Obviously I need to test it before we can make any conclusions.Gormley
@user843732: I think that's where the majority of the saving would come from. I found this which seems to back up the idea that the power consumption of an LCD display does not change due to the colours being shown. But never having done it I can't say for sure, hence my mentioning of needing to test. And I've just realised that it might be different for CRT or LED monitors where you might be able to dim the colour and save energy.Empery
Thanks again for the info. This was a revelation for me, "WIth LCD monitors the darker colours use slightly more power." And also this, "To achieve the maximum savings with either type don't use a screen saver and blank the screen when the computer is idle."Gormley
M
3

Forgive me if this information is outdated, but I have done this in the past using SetDeviceGammaRamp. The 'Get' version is available too for state saving and restore. I have seen it used in C# programs through, so it might still be relevant albeit not too common anymore.

Miki answered 11/8, 2012 at 21:9 Comment(1)
Very nice addition. Thank you! I need to try it out. My only concern is that that API's description says, "Not all direct color video boards support loadable gamma ramps."Gormley

© 2022 - 2024 — McMap. All rights reserved.