RasterOp Class

RasterOp Class

This Package | All Packages

public class RasterOp

The RasterOp class encapsulates a Win32 raster operation. A raster operation refers to a series of boolean operations that you can apply to bitmaps, brushes, and pens. Suppose, for example, that you have two identical images, one of which is black and white, and the other of which is in color. Suppose that you want to write the monochrome image to the colored one, but do not want the white pixels in the source image to overwrite their counterparts in the destination. Raster operations enable you to use boolean logic to express such wishes. You generally build a raster operation using a combination of a series of simple operations and boolean logic. The following raster operations represent the primitives on which you can build. BLACK The resulting pixel(s) will be black. BRUSH The resulting pixel(s) will be the color of the current brush. PEN The resulting pixel(s) will be the color of the current pen. SOURCE The resulting pixel(s) will be the color of the source bitmap image. TARGET The resulting pixel(s) will be the color of the target bitmap image. WHITE The resulting pixel(s) will be white. You can combine one or more simple raster operations using boolean logic to create more complex operations. For example, to draw a line that is always the inverse of the screen color, you would pass the return value of RasterOp.TARGET.invert() as a parameter to a drawing operation defined in the Graphics class. Much more complex effects can be created using boolean AND, OR, and XOR operators.

Fields
Name Description
BLACK The resulting pixels will be black.
BRUSH The resulting pixels will be the color of the current brush.
PEN The resulting pixels will be the color of the current pen.
SOURCE The resulting pixels will be the color of the source image pixels.
TARGET The resulting pixels will be the color of the target image pixels.
WHITE The resulting pixels will be white.

Methods
Name Description
andWith(RasterOp op) Performs a binary AND operation that combines this RasterOp with another.
getRop() Retrieves the ternary ROP code for this raster operation.
getRop2() Retrieves the binary ROP2 code for this raster operation.
invert() Retrieves an RasterOp object that represents an inversion of this one.
orWith(RasterOp op) Performs a binary OR operation that combines this RasterOp with another.
xorWith(RasterOp op) Performs a binary XOR operation that combines this RasterOp with another.

Fields

RasterOp.BLACK

Syntax
public static final RasterOp BLACK;
Description
The resulting pixels will be black.

RasterOp.BRUSH

Syntax
public static final RasterOp BRUSH;
Description
The resulting pixels will be the color of the current brush.

RasterOp.PEN

Syntax
public static final RasterOp PEN;
Description
The resulting pixels will be the color of the current pen.

RasterOp.SOURCE

Syntax
public static final RasterOp SOURCE;
Description
The resulting pixels will be the color of the source image pixels.

RasterOp.TARGET

Syntax
public static final RasterOp TARGET;
Description
The resulting pixels will be the color of the target image pixels.

RasterOp.WHITE

Syntax
public static final RasterOp WHITE;
Description
The resulting pixels will be white.

Methods

RasterOp.andWith

Syntax
public final RasterOp andWith( RasterOp op );
Parameters
op
The RasterOp that participates with this one in the operation.
Return Value

Returns a RasterOp object that represents the result of the binary AND operation.

Description

Performs a binary AND operation that combines this RasterOp with another.

RasterOp.getRop

Syntax
public int getRop();
Return Value

Returns the ternary ROP code for this raster operation.

Description

Retrieves the ternary ROP code for this raster operation.

RasterOp.getRop2

Syntax
public int getRop2();
Return Value

Returns the binary ROP2 code for this raster operation.

Description

Retrieves the binary ROP2 code for this raster operation.

RasterOp.invert

Syntax
public final RasterOp invert();
Return Value

Returns the inverted raster operation.

Description

Retrieves an RasterOp object that represents an inversion of this one.

RasterOp.orWith

Syntax
public final RasterOp orWith( RasterOp op );
Parameters
op
The RasterOp that participates with this one in the operation.
Return Value

Returns a RasterOp object that represents the result of the binary OR operation.

Description

Performs a binary OR operation that combines this RasterOp with another.

RasterOp.xorWith

Syntax
public final RasterOp xorWith( RasterOp op );
Parameters
op
The RasterOp that participates with this one in the operation.
Return Value

Returns a RasterOp object that represents the result of the binary XOR operation.

Description

Performs a binary XOR operation that combines this RasterOp with another.