How do take a screenshot correctly with xlib?
I am trying to capture an image of the screen for use in screencasting. Thus I need a fast solution, and cannot rely on shell programs such as import or xwd. This is the code I have written so far, but it fails and gives me a junk image, which just seems to show fragments of several images with odd colors tossed together. http://s9.postimage.org/dqnkgkwr1/blah.png Any ideas on what I am doing wrong? #include <X11/Xlib.h> #include <X11/X.h> #include <cstdio> #include <CImg.h> using namespace cimg_library; int main() { Display *display = XOpenDisplay(NULL); Window root = DefaultRootWindow