Tag: cimg

使用Cimg库读取jpeg图像时出现堆栈溢出错误

当我尝试使用Cimg库读取jpg文件而其他格式bmp正在工作文件时,我收到堆栈溢出错误。 我该如何解决? #include”CImg.h” #include using namespace cimg_library; int main() { CImg src(“d:\\sidimg.jpg”); int width = src.width(); int height = src.height(); unsigned char* ptr = src.data(0,0); int count=0; while(count!= width*height) { printf(“%d”,*ptr); ptr++; count++; } }

如何使用xlib正确截取屏幕截图?

我正在尝试捕获屏幕图像以用于截屏。 因此我需要一个快速的解决方案,并且不能依赖shell程序,如import或xwd。 这是我到目前为止编写的代码,但是它失败并且给了我一个垃圾图像,它似乎只是显示了几个奇怪颜色的图像片段被拼凑在一起。 http://sofzh.miximages.com/c%2B%2B/blah.png 关于我做错的任何想法? #include #include #include #include using namespace cimg_library; int main() { Display *display = XOpenDisplay(NULL); Window root = DefaultRootWindow(display); XWindowAttributes gwa; XGetWindowAttributes(display, root, &gwa); int width = gwa.width; int height = gwa.height; XImage *image = XGetImage(display,root, 0,0 , width,height,AllPlanes, ZPixmap); unsigned char *array = new unsigned char[width * height * 3]; […]