有什么方法可以从桌面背景获取RGB信息?

问题描述 投票:0回答:1

我想要桌面背景应用程序的RGB颜色信息,并在一定间隔之间输入像素。我该怎么办?

python background-color
1个回答
0
投票

假设您在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)

© www.soinside.com 2019 - 2024. All rights reserved.