Color Output and Mix Attributes

A mix attribute is a bitwise operation on the color indexes in a device's logical color table. Mix attributes enable colors to be specified in relation to other colors. When an application draws a graphics primitive, the operating system uses a mix attribute to determine the color that appears on the output device.

For example, instead of specifying that a line should be black and, therefore, invisible if the background also is black, an application can use a mix attribute of FM_XOR to specify that the line always should be drawn the inverse of the background color.

Suppose an application has set the lColor field in the LINEBUNDLE structure to CLR_RED and the usMixMode field in the same structure to FM_OR. The current color of the drawing surface is CLR_GREEN. To determine the color of a line, the operating system performs a bitwise OR operation on the indexes of these colors, as follows:

          0010  (the default index for red)
          0100  (the default index for green)
         ------
          0110  (result of bitwise OR)

In this case, the result is 6-the index for yellow. This means that even though the application specified CLR_RED in the LINEBUNDLE structure, a yellow line appears when the application calls any of the functions that draw a line primitive.


[Back: Changing the Foreground and Background Colors of Primitives]
[Next: Mix Attribute]