Пример #1
0
static int
FindPixel (ScaleWidget sw, short x, short y,
       short * img_x, short * img_y, unsigned long * img_pixel)
{
  if (sw->scale.table.x[(int) *img_x] + 
      (short) sw->scale.table.width[(int) *img_x] < x)
    {
      ++*img_x;
      return FindPixel (sw, x, y, img_x, img_y, img_pixel);
    }
}
Пример #2
0
void FindPixel (char *windowName, int x, int y, Display *display, Window rootWindow)
{
	Window parent;
	Window *children;
	Window *child;
	XImage *image;
	XWindowAttributes winAttr;
	XColor color;
	XTextProperty wmName;

	unsigned int noOfChildren;
	unsigned long pixel;
	int status;
	int i, red, green, blue;
	char **list;

	status = XGetWMName (display, rootWindow, &wmName);

	if ((status) && (wmName.value) && (wmName.nitems)) {
		if (strcmp(windowName, wmName.value) == 0) {
			XGetWindowAttributes(display, rootWindow, &winAttr);
			image = XGetImage(display, rootWindow, 0, 0, winAttr.width, winAttr.height, XAllPlanes(), ZPixmap);
			color.pixel = XGetPixel(image, x, y);
			XQueryColor(display, XDefaultColormap(display, XDefaultScreen(display)), &color);
			red = floor(color.red * 0.003891051);
			green = floor(color.green * 0.003891051);
			blue = floor(color.blue * 0.003891051);

			printf("%i %i %i\n", red, green, blue);
		}
	}
	
	
	status = XQueryTree (display, rootWindow, &rootWindow, &parent, &children, &noOfChildren);
	
	for (i=0; i < noOfChildren; i++) {
		FindPixel (windowName, x, y, display, children[i]);
	}
	
	XFree ((char*) children);
}
Пример #3
0
int main(int argc, char *argv[])
{
	if (argc != 4) {
		printf("Usage: %s \"Window Name\" <x> <y>\n", argv[0]);
		exit(0);
	}

	// CONNECT TO THE XSERVER
	Display *display;
	int depth;
	int screen;
	int connection;
	char *windowName = argv[1];
	int x = atoi(argv[2]);
	int y = atoi(argv[3]);
	Window window;

	display = XOpenDisplay (NULL);
	screen = DefaultScreen (display);
	depth = DefaultDepth (display, screen);
	connection = ConnectionNumber (display);
	
	// RETRIEVE ROOT WINDOW
	Window rootWindow;
	
	rootWindow = RootWindow (display, screen);	
	// END RETRIEVE ROOT WINDOW
	
	// LOOP THROUGH ALL WINDOWS
	FindPixel (windowName, x, y, display, rootWindow);
	// END LOOP THROUGH ALL WINDOWS
	
	// DISCONNECT FROM THE XSERVER
	XCloseDisplay (display);
	// END DISCONNECT FROM THE XSERVER

	return EXIT_SUCCESS;
}
Пример #4
0
void YARPImageTrackTool::Apply(ImgInt3 frame1, ImgInt3 frame2, int x, int y)
{
	quality = FindPixel(frame1, y, x, frame2, &ty, &tx, blockXSize, blockYSize, windowXSize, windowYSize, windowXOffset, windowYOffset, normalize);
}