Wednesday, July 31, 2024

ConstDisp

With dark themes nearly everywhere these days, I have been noticing that my eyes have a hard time whenever I see white/near-white renderings on my screen - whatever the specifics (webpages, native applications, videos, etc.). I wanted a program that would automatically adjust the brightness accordingly to fit a target brightness I specify. ConstDisp is the result. I first fiddled with a few WMI queries that actually change the screen brightness as one would do using say a keyboard combination (in laptops anyway, not sure if that works with most external monitors) but I ditched that idea because it didn't feel granular enough nor did it seem like it would work with all display hardware. This program works by cheating. All it does is create a topmost window whose background color we choose and whose opacity we modulate to achieve a user-specified target for the "average brightness" of the screen. That's mostly it. Of course, the way it calculates "average brightness" is arbitrary but it's good enough for me. This quantity is simply the mean of all red, green and blue channel values of the pixels of the screen. There could be other ways to get this metric but that's how it's done right now. I wanted to do something open source in C++, so I chose it; for the GUI, I used my SimWin library. In the process, I added a few more features that were needed for this project to SimWin as well. 

Creating the GUI for the program was not fun (really missed C#'s RAD) but implementing the core functionality was, and I got to learn a lot about the language.

Here's a screenshot:




Here's the repo and the binary.

Note: There's no app icon, so it appears as a generic executable. The language standard used here is C++14 but most modern windows should have no problem running the statically linked binary.

No comments:

Post a Comment