cimg

How do take a screenshot correctly with xlib?

倾然丶 夕夏残阳落幕 提交于 2019-11-27 03:41:19
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

Cannot load any image with CImg

可紊 提交于 2019-11-26 22:02:37
问题 Any time I try to load an image I get an error saying CImg<unsigned char>::load(): Failed to recognize format of file . This happens for both jpg and png files. I have found other posts about this saying to define cimg_use_png and cimg_use_jpeg , but then I get compilation errorstelling me I need png.n and jpeglib.h . Not sure where I'm supposed to get these from. I'm not sure where I've gone wrong, so I don't know what to ask specifically. What's gone wrong? 回答1: If you want to open JPEG

How do take a screenshot correctly with xlib?

不羁岁月 提交于 2019-11-26 10:36:00
问题 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. 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