I want to get the RGB value of the top/left pixel (0;0) of the whole x11 display.
what I've got so far:
XColor c;
Display *d = XOpenDisplay((char *) NULL);
XImage *image;
image = XGetImage (d, RootWindow (d, DefaultScreen (d)), x, y, 1, 1, AllPlanes, XYPixmap);
c->pixel = XGetPixel (image, 0, 0);
XFree (image);
XQueryColor (d, DefaultColormap(d, DefaultScreen (d)), c);
cout << c.red << " " << c.green << " " << c.blue << "\n";
but I need those values to be 0..255
or (0.00)..(1.00)
, while they look like 0..57825
, which is no format I recognize.
also, copying the whole screen just to get one pixel is very slow. as this will be used in a speed-critical environment, I'd appreciate if someone knows a more performant way to do this. Maybe using XGetSubImage
of a 1x1 size, but I'm very bad at x11 development and don't know how to implement that.
what shall I do?
cpu 0,054 total
" for a single pixel!). – SekofskiXGetSubImage
would be faster (effectively screencapping only the pixel I need), but dunno how. – Sekofski