This question is similar to this one
Fastest method of screen capturing
but for linux/X11.
To be more specific, i need a method to capture the pixel
I'd grab the sources for gnome-screenshot, or some other existing open-source tool, and figure out how they do it.
gnome-screenshot
You can find the sources Ubuntu uses here: http://packages.ubuntu.com/quantal/gnome-screenshot
But, don't forget to check the license before you cut and paste large sections of code!