[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

No Subject



What is the standard way to get the rgb colors of a pixel in 
a drawing area using GDK?

1) say, in a button_press_event callback, I have the coordinates
event->x, event->y in the drawing area, where the pointer was pressed,
How can I get the 3 unsigned shorts red, green and blue, for that pixel,
that are usually described by a GdkColor structure?

2) The same, but slightly more involved: what is the standard way to get 
an array with the rgb color description of a small square, say, 3x3, 
around the pressed pixel in a drawing area? I need this to pick up objects.

3) I am trying to use the following (Mesa) code to get the rgb
colors of a pressed pixel, but for some reason it is not working
well for me... if some has a clue why this is not always working,
I would appreciate the help...

GLfloat colors[3];
glReadPixels (event->x, event->y, 1, 1, GL_RGB, GL_FLOAT, colors);
printf ("r: %f g: %f b: %f \n", colors[0], colors[1], colors[2]);

Thanks!

Carlos Pereira,
Technical University of Lisboa,
Portugal



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]