7.11 Miscellaneous Color-handling Functions

The following miscellaneous functions provide additional ways to use the color database, to find out the RGB values in a colormap cell, and to free cells that are no longer needed:

XLookupColor()

Looks up a string color name in the color database and returns separate color structures containing the exact RGB values specified in the database for that name and the closest RGB values available on the hardware. This function does not look at any cells in the colormap, even though it has a colormap argument! This argument specifies which screen the color should be looked up on, which is relevant only if each screen has a different color characterization or color database. The difference between XLookupColor() and XParseColor() is that XParseColor() accepts the hexadecimal color specification (which XLookupColor() does not), while XLookupColor() returns the closest colors available on the hardware (which XParseColor() does not). XLookupColor() might be useful for making sure that user-specified colors are contrasting. There is also an Xcms version, XcmsLookupColor(), that is analogous to XLookupColor() except with different arguments and the Xcms version returns a device-independent color specification.

XQueryColor()

Fills an XColor structure with the RGB values corresponding to the colormap cell indicated by a pixel value. Also sets the flags member of the structure to (DoRed | DoGreen | DoBlue). The Xcms version, XcmsQueryColor(), translates the ...

Get XLIB Programming Manual, Rel. 5, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.