次の方法で共有


Binary Raster Operations (Compact 2013)

3/28/2014

Binary raster operation codes define how the graphics device interface (GDI) combines the bits from the selected pen with the bits in the destination bitmap.

This topic lists the binary raster-operation codes used by the GetROP2 and SetROP2 functions.

Each raster-operation code represents a Boolean operation in which the values of the pixels in the selected pen and the destination bitmap are combined.

The following table shows the two operands used in these operations.

Operand

Meaning

P

Selected pen

D

Destination bitmap

The following table shows the Boolean operators used by binary raster operations.

Operator

Meaning

a

Bitwise AND

n

Bitwise NOT (inverse)

o

Bitwise OR

x

Bitwise exclusive OR (XOR)

All Boolean operations are presented in reverse Polish notation. For example, the following operation replaces the values of the pixels in the destination bitmap with a combination of the pixel values of the pen and the selected brush:

DPo 

Each raster-operation code is a 32-bit integer whose high-order word is a Boolean operation index and whose low-order word is the operation code.

The 16-bit operation index is a zero-extended 8-bit value that represents all possible outcomes resulting from the Boolean operation on two parameters (in this case, the pen and destination values).

For example, the following table shows the operation indexes for the DPo and DPan operations.

P

D

DPo

DPan

0

0

0

1

0

1

1

1

1

0

1

1

1

1

1

0

The following table shows the drawing modes and the Boolean operations that they represent.

Raster operation

Boolean operation

R2_BLACK

0

R2_COPYPEN

P

R2_MASKNOTPEN

DPna

R2_MASKPEN

DPa

R2_MASKPENNOT

PDna

R2_MERGENOTPEN

DPno

R2_MERGEPEN

DPo

R2_MERGEPENNOT

PDno

R2_NOP

D

R2_NOT

Dn

R2_NOTCOPYPEN

Pn

R2_NOTMASKPEN

DPan

R2_NOTMERGEPEN

DPon

R2_NOTXORPEN

DPxn

R2_WHITE

1

R2_XORPEN

DPx

For a monochrome device, GDI maps the value 0 to black and the value 1 to white.

The following table shows the results for an application that attempts to draw with a black pen on a white destination by using the available binary raster operations.

Raster operation

Result

R2_BLACK

Visible black line

R2_COPYPEN

Visible black line

R2_MASKNOTPEN

No visible line

R2_MASKPEN

Visible black line

R2_MASKPENNOT

Visible black line

R2_MERGENOTPEN

No visible line

R2_MERGEPEN

Visible black line

R2_MERGEPENNOT

Visible black line

R2_NOP

No visible line

R2_NOT

Visible black line

R2_NOTCOPYPEN

No visible line

R2_NOTMASKPEN

No visible line

R2_NOTMERGEPEN

Visible black line

R2_NOTXORPEN

Visible black line

R2_WHITE

No visible line

R2_XORPEN

No visible line

For a color device, GDI uses RGB values to represent the colors of the pen and the destination.

An RGB color value is a long integer that contains a red, a green, and a blue color field, each specifying the intensity of the specified color. Intensities range from 0 through 255.

The values are packed in the three low-order bytes of the long integer.

The color of a pen is always a solid color, but the color of the destination may be a mixture of any two or three colors.

The following table shows the results for an application that attempts to draw with a white pen on a blue destination by using the available binary raster operations.

Raster operation

Result

R2_BLACK

Visible black line

R2_COPYPEN

Visible white line

R2_MASKNOTPEN

Visible black line

R2_MASKPEN

Invisible blue line

R2_MASKPENNOT

Visible red/green line

R2_MERGENOTPEN

Invisible blue line

R2_MERGEPEN

Visible white line

R2_MERGEPENNOT

Visible white line

R2_NOP

Invisible blue line

R2_NOT

Visible red/green line

R2_NOTCOPYPEN

Visible black line

R2_NOTMASKPEN

Visible red/green line

R2_NOTMERGEPEN

Visible black line

R2_NOTXORPEN

Invisible blue line

R2_WHITE

Visible white line

R2_XORPEN

Visible red/green line

See Also

Reference

Raster Operation Codes
Ternary Raster Operations
GetROP2
SetROP2