Related topics include:
For an overview and a list of lookup tables, see Lookup Tables.
Color approximation lookup tables hold the information necessary to convert PEX colors to X11 colormap pixel values.
---------------------------------------------------------------------------------------------- Table Value Description Fallback PEX Mask ---------------------------------------------------------------------------------------------- PEXLUTVColorApproxMethod 5.0 color approximation type (imp-dep) PEXLUTVColorApproxModel 5.0 color approximation model (imp-dep) PEXLUTVColorApproxMax1 5.0 max1 (imp-dep) PEXLUTVColorApproxMax2 5.0 max2 (imp-dep) PEXLUTVColorApproxMax3 5.0 max3 (imp-dep) PEXLUTVColorApproxDither 5.0 dither (imp-dep) PEXLUTVColorApproxMult1 5.0 mult1 (imp-dep) PEXLUTVColorApproxMult2 5.0 mult2 (imp-dep) PEXLUTVColorApproxMult3 5.0 mult3 (imp-dep) PEXLUTVColorApproxWeight1 5.0 weight1 (imp-dep) PEXLUTVColorApproxWeight2 5.0 weight2 (imp-dep) PEXLUTVColorApproxWeight3 5.0 weight3 (imp-dep) PEXLUTVColorApproxBasePixel 5.0 base pixel (imp-dep) PEXLUTVColorApproxAll (selects entire table entry) 5.0 ----------------------------------------------------------------------------------------------
Color approximation converts colors computed by the PEX rendering pipeline to pixel values. The PEX rendering pipeline produces a color in a multi-dimensional color space such as RGB. The PEX color approximation process converts that color, called the input color, to a pixel value that selects an entry in an X11 colormap. The method and arguments used to convert the color are taken from the color approximation table entry indicated by the pipeline state's color approximation index. Alpha values are unaffected by color approximation.
PEXlib defines the following values:
After the input color is converted to the color approximation color model, the converted color is converted to a pixel value according to the method you indicate by the color approximation type in the selected table entry.
The
are conceptually rounded to integers in this operation.
max1, max2, and max3 typically indicate the number of samplings (minus 1) of each color component in a colormap organized as a color cube. For example, the max values in a colormap organized as a 3-3-2 color cube are 7, 7, 3 (23-1, 23-1, 22-1). Thus, the equation serves to scale the color coordinates into the available range of discrete colors.
The
are converted to a pixel value by the formula given in the following
equation:
(1)
ColorSpace color approximation does not use the weight1, weight2, and weight3 values in the color approximation entry.
The weights may emphasize, minimize, or eliminate one or more of the color components. For example, weights of (.299R,.587G,.114B) convert an RGB value to a single-valued intensity used in the NTSC color standard. Typically, you should normalize the weights so that they sum to 1; PEX does not normalize the weights.
After the weights are applied, the computed value, V, is multiplied by max1 in the color approximation entry:
max2 and max3 are not used.
The value V' is replicated for each of the three color components. Each component is then multiplied by mult1, mult2, or mult3, respectively, and the values are added together with base pixel to form the pixel value, P, written to the drawable: (2)
max1 is typically one less than the number of entries in a colormap. For example, a value of 99 for max1 scales colors to the range [0, 99], and might be used to display an image in gray scale using a colormap with 100 contiguous shades of gray. Typically mult1 is 1 and mult2 and mult3 are 0. PEX supports mult2 and mult3 so you can simulate gray ramps on a DirectColor visual by replicating the intensity in all three channels of the pixel.
Restrictions and Errors
Valid color approximation lookup table indices are in the range [0, 65534]. The fallback entry is entry 0.
For an overview of the color approximation lookup table, see Color Approximation Table.
Inquire BestColorApproxValues with request PEXGetImpDepConstants to determine what values, if any, of mult1, mult2, and mult3 are likely to result in the best performance.
For an overview of the color approximation lookup table, see Color Approximation Table.
dither is a hint to the renderer as to whether some attempt at dithering (manipulation of pixel values in order to smooth the image) should be performed. With request PEXGetImpDepConstants inquire DitheringSupported to determine if the implementation can dither, and, if the implementation does support dithering, inquire DitheringControllable to determine if you can disable dithering with the dithering hint. Though the implementation might support dithering, the algorithm used is implementation-dependent.
The color approximation table is always accessed when rendering. The value of the pipeline state's color approximation index selects the desired entry of the table.
If you specify an unsupported color approximation type or unsupported color approximation model, then the implementation issues a BadValue error.