缺少X11 / Xlib.h中的XGetPixel()?

时间:2016-07-24 17:49:04

标签: c++ linux ubuntu x11 xorg

我正在编写一个使用XGetPixel()方法的程序。但是,在使用它时我得到一个错误说"错误:XGetPixel未在此范围内声明"

我的代码如下:

#include <X11/Xlib.h>
#include <X11/X.h>
#include <unistd.h>
#include <iostream>
using namespace std;

int main()
{
    // Open a display.
    Display *d = XOpenDisplay(NULL);

    // Get the root of the display
    Window root = DefaultRootWindow(d);

    // Map the root window
    XMapWindow(d, root);

    // Get width and height of the display
    int windowHeight = XDisplayHeight (d, 0);
    int windowWidth = XDisplayWidth(d, 0);

    // Get dump of screen
    XImage *image = XGetImage(d, root, 0, 0, windowWidth, windowHeight, AllPlanes, ZPixmap);

    XGetPixel(image,5,5);

    return 0;
}

奇怪的是,当我签入X11 / Xlib.h时,它似乎甚至没有XGetPixel()方法或结构。这可能是一个错误吗?我目前正在使用Ubuntu 16并使用apt-get libx11-dev安装它,我找不到任何有关此问题的报告问题。

1 个答案:

答案 0 :(得分:4)

图像处理函数在#include <X11/Xutil.h>定义。