2.2 Displaying bitmaps on the screen

2.2.5 Using boolean operations with bitmaps

The function bitblt allows you to copy via block transfer a block or region of bits in a bitmap; it also allows you to specify the logical boolean operation that describes how the bits in the source and destination bitmaps should be combined. For a list of the boolean operations and their logical meanings, see Common Lisp: The Language, 2nd edition, by Guy L. Steele, Jr. (hereafter referred to as CLtL2).

Create a new bitmap and window, and usebitblt to copy the image in the first bitmap onto the new bitmap. Then copy a portion of the first bitmap onto itself:

(setq *window2* (make-window :width 100 :height 100 :x 110))
(bitblt *window* 0 0 *window2* 0 0 100 100 boole-1)
(bitblt *window* 0 0 *window* 0 50 100 50 boole-1)
The boolean operationboole-1copies the source bitmap's bits and ignores any set or cleared bits in the destination bitmap.

The following example uses the functionbitblt to copy from*window* to*window2* by using boolean operationboole-c1, which complements the source bits in the first window's bitmap. When you copy from*window2* to itself usingboole-c1, the original image returns:

(clear-bitmap *window2*)
(bitblt *window* 0 0 *window2* 0 0 100 100 boole-c1)
(bitblt *window2* 0 0 *window2* 0 0 100 100 boole-c1)
Many Window Tool Kit functions require a boolean operation that describes how bits should be set or combined during that operation. For graphics output, you use the boolean operationboole-1 most often, but the other boolean operations are also useful and are supported.

The Window Tool Kit - 9 SEP 1996

Generated with Harlequin WebMaker