如何在Windows 7上使用python / pygame关闭某些像素

时间:2019-07-10 02:21:16

标签: python windows windows-7 pygame pixel

我有一台旧的Windows 7笔记本电脑,我想把它变成一个简单的时钟。我用pygame将(0,0,0)黑色像素填充到屏幕上,然后在上面用浅蓝色像素绘制时间。

The clock when all lights are off in the room

问题是(0,0,0)黑色像素与关闭的像素不同。从图片中可以看出,即使笔记本电脑的亮度尽可能低,黑色像素仍然具有亮度。这使时钟就像小夜灯一样,这不是我想要的。

我希望那些黑色像素完全消失(例如关闭笔记本电脑且屏幕没有亮度),同时保持蓝色像素亮着。有什么建议么?这有可能吗?

如果可能的话,我猜想解决方案是更改Windows 7设置中的某些内容,或者执行pygame或其他python库未想到的某些事情。

-迄今为止的研究-

对此帖子的最高答复称,无法“关闭”计算机端的像素:https://superuser.com/questions/1155129/how-to-turn-off-make-black-certain-pixels-on-a-screen

有趣的建议,例如在Windows中更改对比度设置或下载调光器程序,尽管OP表示这两个想法都不足够:https://answers.microsoft.com/en-us/windows/forum/windows_7-desktop/how-do-i-dim-the-screen-brightness-further-than/ad7388af-e07a-4d9b-b71d-0e3f77a61c1c

背光信息:https://www.google.com/amp/s/amp.reddit.com/r/explainlikeimfive/comments/3hm6pd/eli5_why_dont_pixels_that_show_the_color_black/

1 个答案:

答案 0 :(得分:1)

虽然无法打开或关闭LED显示器的特定像素,但可以控制显示器后面的光(背光)。

这意味着时钟可以在白天打开,而在晚上可以完全关闭-不幸的是,它永远不能像问题所希望的那样部分打开。

用于打开和关闭背光的Python代码(对于Windows,睡眠也是一种选择):

def backlight(argument):
    if sys.platform.startswith('linux'): # expecting "on" or "off" as the argument
        import os
        os.system("xset dpms force " + argument)

    elif sys.platform.startswith('win'): # expecting "on", "off", or "sleep" as the argument
        import win32gui
        import win32con

        if argument == "on":
          win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SYSCOMMAND,
                               win32con.SC_MONITORPOWER, -1)
        if argument == "off":
          win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SYSCOMMAND,
                               win32con.SC_MONITORPOWER, 2)
        if argument == "sleep":
          win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SYSCOMMAND,
                               win32con.SC_MONITORPOWER, 1)