Color of a screen pixel: Difference between revisions
Content deleted Content added
No edit summary |
|||
Line 20: | Line 20: | ||
=={{header|C}}== |
=={{header|C}}== |
||
{{libheader|Xlib}} |
|||
<lang c> |
|||
#include <X11/xlib.h> |
|||
void |
|||
get_pixel_color (Display *d, int x, int y, XColor *color) |
|||
{ |
|||
XImage *image; |
|||
image = XGetImage (d, RootWindow (d, DefaultScreen (d)), x, y, 1, 1, AllPlanes, XYPixmap); |
|||
color->pixel = XGetPixel (image, 0, 0); |
|||
XFree (image); |
|||
XQueryColor (d, DefaultColormap(d, DefaultScreen (d)), color); |
|||
} |
|||
// Your code |
|||
XColor c; |
|||
get_pixel_color (display, 30, 40, &c); |
|||
printf ("%d %d %d\n", c.red, c.green, c.blue); |
|||
</lang> |
|||
{{works with|Windows}}. It uses Windows API |
{{works with|Windows}}. It uses Windows API |
||