2016-07-24 59 views
2

我在寫一個使用XGetPixel()方法的程序。然而,在使用它,我得到一個錯誤說「錯誤:XGetPixel沒有在這個範圍內聲明」在X11/Xlib.h中缺少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進行安裝,我無法找到任何有關此問題的報告問題。

回答

2

圖像處理函數定義在#include <X11/Xutil.h>

+1

謝謝!我正在查看各種示例,他們只使用,這是變化還是總是在Xutil.h下? – Jack

+1

它隨着時間而改變。 –