Mix Attribute

The mix attribute determines how each primitive an application draws is combined with any existing drawing. In color applications, the mix attribute determines the color that results when one primitive is drawn on top of another. There are two forms of the mix attribute: foreground mix and background mix.

The foreground mix attribute governs how the foreground of a primitive is combined with the existing drawing, and it applies to all primitive types. The background mix attribute governs how the background of a primitive is combined with the existing drawing, and it is applicable only to those primitives that have a background. Primitives that can be affected by the background mix attribute are areas, character strings, images, and markers. The primitive attribute data structures contain fields for both foreground and background color and mix attributes.

There are 17 foreground mix attributes. For each mix attribute, the indexes of the foreground and current drawing-surface colors are combined by using one of the bitwise operators. The available foreground mix settings are listed in the following table.

Foreground Mix Attributes

┌───────────────┬───────────────┬──────────────────────────────┐
│Mix Attribute  │Effect         │Description                   │
├───────────────┼───────────────┼──────────────────────────────┤
│FM_DEFAULT     │Default        │Default foreground mix        │
│               │               │attribute (overpaint).        │
├───────────────┼───────────────┼──────────────────────────────┤
│FM_OR          │OR             │Index value of the final color│
│               │               │is determined by a bitwise OR │
│               │               │operation on the index of the │
│               │               │foreground color and the index│
│               │               │of the color of the drawing   │
│               │               │surface.                      │
├───────────────┼───────────────┼──────────────────────────────┤
│FM_OVERPAINT   │Overpaint      │Index value of the final color│
│               │               │is that of the foreground     │
│               │               │color. This is the default    │
│               │               │foreground mix attribute.     │
├───────────────┼───────────────┼──────────────────────────────┤
│FM_XOR         │Exclusive-OR   │Index value of the final color│
│               │(XOR)          │is determined by a bitwise XOR│
│               │               │operation on the index of the │
│               │               │foreground color and the index│
│               │               │of the color of the drawing   │
│               │               │surface.                      │
├───────────────┼───────────────┼──────────────────────────────┤
│FM_LEAVEALONE  │Leave-alone    │Index value of the final color│
│               │(Invisible)    │is that of the index of the   │
│               │               │color of the drawing surface. │
├───────────────┼───────────────┼──────────────────────────────┤
│FM_AND         │AND            │Index value of the final color│
│               │               │is determined by a bitwise AND│
│               │               │operation on the index of the │
│               │               │foreground color and the index│
│               │               │of the color of the drawing   │
│               │               │surface.                      │
├───────────────┼───────────────┼──────────────────────────────┤
│FM_SUBTRACT    │(Inverse       │Index value of the final color│
│               │Source) AND    │is determined by inverting the│
│               │Destination    │index of the foreground color │
│               │               │and performing a bitwise AND  │
│               │               │operation on this value and   │
│               │               │the index of the color of the │
│               │               │drawing surface.              │
├───────────────┼───────────────┼──────────────────────────────┤
│FM_MASKSRCNOT  │Source AND     │Index value of the final color│
│               │(Inverse       │is determined by inverting the│
│               │Destination)   │index value of the            │
│               │               │drawing-surface color and     │
│               │               │performing a bitwise AND      │
│               │               │operation on this value and   │
│               │               │the index value of the        │
│               │               │foreground color.             │
├───────────────┼───────────────┼──────────────────────────────┤
│FM_ZERO        │All zeros      │RGB value of the final color's│
│               │               │is always 0x00000000.         │
├───────────────┼───────────────┼──────────────────────────────┤
│FM_NOTMERGESRC │Inverse (Source│Index value of the final color│
│               │OR Destination)│is always the inverse of the  │
│               │               │FM_OR result.                 │
├───────────────┼───────────────┼──────────────────────────────┤
│FM_NOTXORSRC   │Inverse (Source│Index value of the final color│
│               │XOR            │is always the inverse of the  │
│               │Destination)   │FM_XOR result.                │
├───────────────┼───────────────┼──────────────────────────────┤
│FM_INVERT      │Inverse        │Index value of the final color│
│               │(Destination)  │is always the inverse of the  │
│               │               │index of the color of the     │
│               │               │drawing surface.              │
├───────────────┼───────────────┼──────────────────────────────┤
│FM_MERGESRCNOT │Source OR      │Index value of the final color│
│               │(Inverse       │is determined by performing a │
│               │Destination)   │bitwise OR operation on the   │
│               │               │index of the foreground color │
│               │               │and the inverse of the index  │
│               │               │of the color of the drawing   │
│               │               │surface.                      │
├───────────────┼───────────────┼──────────────────────────────┤
│FM_NOTCOPYSRC  │Inverse        │Index value of the final color│
│               │(Source)       │is the inverse of the index of│
│               │               │the foreground color.         │
├───────────────┼───────────────┼──────────────────────────────┤
│FM_MERGENOTSRC │(Inverse       │Index value of the final color│
│               │Source) OR     │is determined by performing a │
│               │Destination    │bitwise AND operation on the  │
│               │               │index of the drawing surface's│
│               │               │color and the inverse of the  │
│               │               │index of the foreground color.│
├───────────────┼───────────────┼──────────────────────────────┤
│FM_NOTMASKSRC  │Inverse (Source│Index value of the final color│
│               │AND            │is the inverse of the FM_AND  │
│               │Destination)   │result.                       │
├───────────────┼───────────────┼──────────────────────────────┤
│FM_ONE         │All 1's.       │RGB value of the final color  │
│               │               │is always 0x00FFFFFF.         │
└───────────────┴───────────────┴──────────────────────────────┘

There are five background mix attributes. For each mix attribute, the index value for the background color and the current drawing-surface color (in the device's physical color table) are combined using one of the bitwise operators.

The RGB values are those from the physical color table. When the result of the mix attribute's bitwise operation defines a color different from that of both the drawing surface and the drawing attribute, the resulting index accesses an RGB color in the physical table. The color, therefore, is unpredictable unless the logical color table has been realized (using the palette manager).

The first five of the foreground mix attributes also are available as background mix attributes. The background mix attributes are listed in the following table.

Background Mix Attributes

┌───────────────┬───────────────┬──────────────────────────────┐
│Mix Attribute  │Effect         │Description                   │
├───────────────┼───────────────┼──────────────────────────────┤
│BM_DEFAULT     │Default        │Default background mix        │
│               │               │attribute (Leave-alone).      │
├───────────────┼───────────────┼──────────────────────────────┤
│BM_OR          │OR             │Index value of the final color│
│               │               │is determined by a bitwise OR │
│               │               │operation on the index of the │
│               │               │background color and the index│
│               │               │of the color of the drawing   │
│               │               │surface.                      │
├───────────────┼───────────────┼──────────────────────────────┤
│BM_OVERPAINT   │Overpaint      │Index value of the final color│
│               │               │is that of the background     │
│               │               │color.                        │
├───────────────┼───────────────┼──────────────────────────────┤
│BM_XOR         │Exclusive-OR   │Index value of the final color│
│               │(XOR)          │is determined by a bitwise XOR│
│               │               │operation on the index of the │
│               │               │background color and the index│
│               │               │of the color of the drawing   │
│               │               │surface.                      │
├───────────────┼───────────────┼──────────────────────────────┤
│BM_LEAVEALONE  │Leave-alone    │Index value of the final color│
│               │(Invisible)    │is that of the drawing-surface│
│               │               │color.                        │
└───────────────┴───────────────┴──────────────────────────────┘

The most frequently used foreground mix attributes are FM_OVERPAINT, which is the default value, FM_OR, and FM_XOR. The most frequently used background mix attributes are BM_LEAVEALONE, which is the default value, and BM_OVERPAINT.


[Back: Color Output and Mix Attributes]
[Next: Overpaint Mix Attribute]