Color of a screen pixel: Difference between revisions

→‎{{header|Python}}: Libheader and works_with templates, as available.
(→‎{{header|Python}}: added pygtk version)
(→‎{{header|Python}}: Libheader and works_with templates, as available.)
Line 61:
 
=={{header|Python}}==
{{libheader|ImageGrab}}
Windows:
 
{{works_with|Windows}}
<lang python>from PIL import ImageGrab
pixels = ImageGrab.grab().load()
print pixels[0,0]</lang>
{{libheader|xlib}}
Xorg/Xlib (Linux, BSD, Unix):
<lang python>def get_pixel_colour(i_x, i_y):
import Image # python-imaging
Line 78 ⟶ 80:
return i_mean_colour
print get_pixel_colour(0, 0)</lang>
{{libheader|Qt}}
Qt:
<lang python>def get_pixel_colour(i_x, i_y):
import PyQt4.QtGui # python-qt4
Line 87 ⟶ 89:
return ((i_qcolor & 0xff0000) >> 16), ((i_qcolor & 0xff00) >> 8), (i_qcolor & 0xff)
print get_pixel_colour(0, 0)</lang>
{{libheader|Gtk+}}
GTK+:
<lang python>def get_pixel_colour(i_x, i_y):
import gtk # python-gtk2