【问题标题】:Is there any way I can get the RGB information from the desktop background?有什么方法可以从桌面背景获取 RGB 信息?
【发布时间】:2020-08-17 20:11:37
【问题描述】:

我想要桌面背景应用程序的 RGB 颜色信息,其中像素作为特定间隔之间的输入。我该怎么做?

【问题讨论】:

  • 你的意思是你有一张图片,你想要这张图片里面像素的RGB吗?
  • 不是图片,但我想获取桌面应用程序的颜色信息

标签: python background-color


【解决方案1】:

假设您在 windows/macOS 上,您可以使用 PIL 或它的 fork Pillow,如下所示:

import PIL.ImgaeGrab  # Pillow is also imported as PIL

x = y = 10
pixel = (x, y)

scrn = PIL.ImageGrab.grab()
scrn.getpixel(pixel)
>>> (246, 138, 30) # The result for me

对于其他捕获屏幕的方法,您可以查看here

对于时间间隔,只需使用time.sleep(seconds)

【讨论】:

    猜你喜欢
    • 2013-03-26
    • 2019-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多