Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ XParseColor(3x) — HP-UX ANSI C A.10.11

Media Vault

Software Library

Restoration Projects

Artifacts Sought

 

NAME

XParseColor − look up RGB values from ASCII color name or translate hexadecimal value. 

Synopsis

Status XParseColor(display, colormap, spec, exact_def_return)
Display *display;
Colormap colormap;
char *spec;
XColor *exact_def_return;

Arguments

displaySpecifies a connection to an X server; returned from XOpenDisplay(). 

colormapSpecifies a colormap associated with the screen on which to look up the color.  This argument is required, but is meaningful only with Xcms color specifications. 

specSpecifies the color string (see Description).  Upper or lower case does not matter.  If the color name is not in the Host Portable Character Encoding, the result is implementation-dependent. 

exact_def_return
Returns the RGB values corresponding to the specified color name or hexadecimal specification, and sets its DoRed, DoGreen and DoBlue flags. 

Description

XParseColor() looks up the string name of a color with respect to the screen associated with the specified colormap.  It returns the exact color value.  It or hexadecimal values specified, or translating the hexadecimal code into separate RGB values.  XParseColor() takes a string specification of a color, typically from a user-specified command line or resource value, and returns the corresponding red, green, and blue values, suitable for a subsequent call to XAllocColor or XStoreColor().  spec can be given in several forms, and may be looked up in different ways depending on the form. 

•Color name, such as "blue".  This form is looked up in the server’s RGB database, a sample of which is listed in Appendix D, The Color Database. 

•Xcms color name, such as TekHVC:0.0/100.0/0.0.  This form is looked up in the client-side database for the screen associated with the specified colormap.  This form is supported starting in Release 5.  For more information on this form of color specification, see the Programmer’s Supplement for Release 5, or the Third Edition of Volume One. 

•Hexadecimal specification such as #3a7.  This form consists of an initial sharp sign character followed by one of the following formats:

#RGB(one character per color)
#RRGGBB(two characters per color)
#RRRGGGBBB(three characters per color)
#RRRRGGGGBBBB(four characters per color)

where R, G, and B represent single hexadecimal digits (upper or lower case).  The hexadecimal strings must be null-terminated so that XParseColor() knows when it has reached the end.  When fewer than 16 bits each are specified, they represent the most significant bits of the value.  For example, #3a7 is the same as #3000a0007000.  The hexadecimal style is discouraged in Release 5 and later.  Status is zero on failure, nonzero on success.  This routine will fail if the initial character is a sharp sign but the string otherwise fails to fit one of the above formats, or if the initial character is not a sharp sign and the named color does not exist in the server’s database.  For more information, see Volume One, Chapter 7, Color and in the Third Edition, the chapter on Device-Independent Color. 

Structures

.nf typedef struct { unsigned long pixel;  unsigned short red, green, blue;  char flags; /* DoRed, DoGreen, DoBlue */  char pad; } XColor;

Errors

BadColorInvalid colormap. 

See Also

BlackPixel(), WhitePixel(), XAllocColor(), XcmsAllocColor(), XAllocColorCells(), XAllocColorPlanes(), XFreeColors(), XLookupColor(), XQueryColor(), XQueryColors(), XStoreColor(), XcmsStoreColor(), XStoreColors(), XcmsStoreColors(),

Copyright O’Reilly & Assoc.  —  

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026