Find the answer to your Linux question:
Results 1 to 3 of 3
Hi everyone... I'm working with XLib and I want to find out the pixel value of a particular point on screen and then map it to RGB values. I used ...
  1. #1
    Just Joined!
    Join Date
    Apr 2007
    Posts
    8

    Question XLib - Mapping Pixel Values to RGB

    Hi everyone...
    I'm working with XLib and I want to find out the pixel value of a particular point on screen and then map it to RGB values. I used XGetImage and XGetPixel to get the pixel value, but how do I get the RGB values of the pixel?
    I went through a few XLib manuals, there seems to be no way. Any solution?

  2. #2
    Linux Newbie
    Join Date
    Jan 2008
    Location
    UK
    Posts
    211
    Hi, The colormap is a lookup table located on the server the pixel value is used as an index into the table.
    So, you want to use XQueryColor function:

    XQueryColor(display, colormap, def_in_out)
    Display *display;
    Colormap colormap;
    XColor *def_in_out;

    The XQueryColor() function returns the current RGB value for the pixel in the XColor structure and sets the DoRed, DoGreen, and DoBlue flags.

    XQueryColor() can generate BadColor and BadValue errors.

    BadColor A value for a Colormap argument does not name a defined Colormap.
    BadValue Some numeric value falls outside the range of values accepted by the request. Unless a specific range is specified for an argument, the full range defined by the argument's type is accepted. Any argument defined as a set of alternatives can generate this error.

    Hope this helps

  3. #3
    Just Joined!
    Join Date
    Apr 2007
    Posts
    8

    Cool

    That's exactly what I wanted, thanks... Helped a lot

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...