I want to get the RGB value of the top / left pixel (0; 0) of the whole x11 display.
what I still have:
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 these values ββto be 0..255 or (0.00)..(1.00) , while they look like 0..57825 , which do not match the format.
also, copying the entire screen to get one pixel is very slow. since it will be used in mission-critical environments, I would appreciate it if someone knows a more efficient way to do this. Perhaps using XGetSubImage size of 1x1, but I am very poorly versed in x11 development and do not know how to implement this.
what should I do?
source share