Jump to content

Color of a screen pixel: Difference between revisions

→‎{{header|Python}}: Added parenthesis to print to make examples python3 compatible (hopefully), minor fixes
(→‎{{header|Tcl}}: + Standard ML)
(→‎{{header|Python}}: Added parenthesis to print to make examples python3 compatible (hopefully), minor fixes)
Line 755:
=={{header|Python}}==
{{libheader|PyWin32}}
{{works_with|Windows}}
<lang python>def get_pixel_colour(i_x, i_y):
import win32gui
Line 764 ⟶ 765:
return (i_colour & 0xff), ((i_colour >> 8) & 0xff), ((i_colour >> 16) & 0xff)
 
print (get_pixel_colour(0, 0))</lang>
 
{{libheader|PIL}}
 
{{works_with|Windows}} only
<lang python>def get_pixel_colour(i_x, i_y):
import PIL.ImageGrab
return PIL.ImageGrab.grab().load()[i_x, i_y]
 
print (get_pixel_colour(0, 0))</lang>
{{libheader|PIL}}
{{libheader|python-xlib}}
Line 786 ⟶ 787:
return tuple(map(int, lf_colour))
 
print (get_pixel_colour(0, 0))</lang>
{{libheader|PyGTK}}
<lang python>def get_pixel_colour(i_x, i_y):
Line 794 ⟶ 795:
return tuple(o_gdk_pixbuf.get_pixels_array().tolist()[0][0])
 
print (get_pixel_colour(0, 0))</lang>
{{libheader|PyQt}}
<lang python>def get_pixel_colour(i_x, i_y):
Line 804 ⟶ 805:
return ((i_colour >> 16) & 0xff), ((i_colour >> 8) & 0xff), (i_colour & 0xff)
 
print (get_pixel_colour(0, 0))</lang>
 
=={{header|Racket}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.