Getting screenshot and find location of multiple smaller images in it in linux

view story

http://stackoverflow.com – I want to get a screenshot of a x11 window and find the location of smaller images in it. I've had no experiences with working with images, I searched a lot, but I don't get much helpful results. The image are from files and can be loaded with any format that is easier to use. The getting screenshot is easy, using XGetImage. But then the question is that which format to use XYPixmap or ZPixmap? What's the difference? How each pixel is represented? And then what about the images? Which file format is easier to use? And then how each pixel is represented in that format? And which algorithm sh (HowTos)