[英]How to get list of pixel coordinates[x, y] of certain color(RGB) with python?
[英]Is it possible to get the color of a particular pixel on the screen with it's X and Y coordinates?
我想使用其XY坐標獲取Python中特定像素的顏色,這可能嗎?
如果有幫助,請在Windows中使用。
請參閱python標題下的http://rosettacode.org/wiki/Color_of_a_screen_pixel
他們給:
def get_pixel_colour(i_x, i_y):
import win32gui
i_desktop_window_id = win32gui.GetDesktopWindow()
i_desktop_window_dc = win32gui.GetWindowDC(i_desktop_window_id)
long_colour = win32gui.GetPixel(i_desktop_window_dc, i_x, i_y)
i_colour = int(long_colour)
return (i_colour & 0xff), ((i_colour >> 8) & 0xff), ((i_colour >> 16) & 0xff)
print get_pixel_colour(0, 0)
使用適用於Windows的Python擴展程序,該擴展程序適用於python 2.3至3.1, 網址為http://sourceforge.net/projects/pywin32/files/pywin32/Build%20214/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.