Jack
Jack

Reputation: 304

Missing XGetPixel() in X11/Xlib.h?

I am writing a program that uses the XGetPixel() method. However, upon using it I get an error saying "Error: XGetPixel was not declared in this scope"

My code is the following:

#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;
}

Strangely, when I check in the X11/Xlib.h it dosn't appear to even have a XGetPixel() method or structure. Is it possible this is a bug? I am currently using Ubuntu 16 and installed it using apt-get libx11-dev and I cannot find any reported issues about this problem.

Upvotes: 5

Views: 1440

Answers (1)

Jean Pierre Dudey
Jean Pierre Dudey

Reputation: 665

Image manipulation functions are defined at #include <X11/Xutil.h>.

Upvotes: 7

Related Questions