int SetROP2(hDC,nDrawMode)
This function sets the current drawing mode. GDI uses the drawing mode to combine pens and interiors of filled objects with the colors already on the display surface. The mode specifies how the color of the pen or interior and the color already on the display surface yield a new color.
Parameter | Type/Description |
hDC | HDC Identifies the device context. | |
nDrawMode | int Specifies the new drawing mode. It can be any one of the values given in Table R.16, “Drawing Modes.” |
The return value specifies the previous drawing mode.
Drawing modes define how GDI combines source and destination colors when drawing with the current pen. The drawing modes are actually binary raster-operation codes, representing all possible Boolean functions of two variables, using the binary operations AND, OR, and XOR (exclusive OR), and the unary operation NOT. The drawing mode is for raster devices only; it is not available on vector devices. For more information, see the RC_BITBLT capability in the GetDeviceCaps function, earlier in this chapter. Table R.16 shows the value of various drawing modes for the nDrawMode parameter:
Table R.16 Drawing Modes
Value | Meaning |
R2_BLACK | Pixel is always black. |
R2_WHITE | Pixel is always white. |
R2_NOP | Pixel remains unchanged. |
R2_NOT | Pixel is the inverse of the display color. |
R2_COPYPEN | Pixel is the pen color. |
R2_NOTCOPYPEN | Pixel is the inverse of the pen color. |
R2_MERGEPENNOT | Pixel is a combination of the pen color and the inverse of the display color. |
R2_MASKPENNOT | Pixel is a combination of the colors common to both the pen and the inverse of the display. |
Table R.16 Drawing Modes (continued)
Value | Meaning |
R2_MERGENOTPEN | Pixel is a combination of the display color and the inverse of the pen color. | |
R2_MASKNOTPEN | Pixel is a combination of the colors common to both the display and the inverse of the pen. | |
R2_MERGEPEN | Pixel is a combination of the pen color and the display color. | |
R2_NOTMERGEPEN | Pixel is the inverse of the R2_MERGEPEN color. | |
R2_MASKPEN | Pixel is a combination of the colors common to both the pen and the display. | |
R2_NOTMASKPEN | Pixel is the inverse of the R2_MASKPEN color. | |
R2_XORPEN | Pixel is a combination of the colors in the pen and in the display, but not in both. | |
R2_NOTXORPEN | Pixel is the inverse of the R2_XORPEN color. | |