2.2 Displaying bitmaps on the screen

2.2.1 Making a bitmap

You can use the function make-bitmap to create a bitmap of the specified dimensions:

(setq *bitmap* (make-bitmap :width 100 :height 100))
To draw a line on the newly created bitmap, enter the following expression:

(draw-line *bitmap* (make-position 0 0) (make-position 100 100))
The line drawn on*bitmap* is not visible because*bitmap* must be associated with a viewport or a window to be seen on the display, as in the following example:

(setq *viewport1*
      (make-viewport :bitmap *bitmap* :width 100 :height 100))

You now see a diagonal line on the screen where*viewport1* maps*bitmap* onto the screen. Though you used a viewport in this example, you could have used a window instead to map*bitmap* onto the screen.

Since*bitmap* is already mapped onto the screen, anything you draw on it shows on the screen immediately:

(draw-circle *bitmap* (make-position 50 50) 30)
Viewports do not automatically associate bitmap output streams with their bitmaps. Thus, to format text onto*bitmap*, you must associate a bitmap output stream with the bitmap, as in the following example:

(setq *bitmap-output-stream*
      (make-bitmap-output-stream :bitmap *bitmap*))

(format *bitmap-output-stream* "ABC 123")

There are other ways of sending text to a bitmap that do not require creating a bitmap output stream; see Section 2.2.4 on page 19 for more information.

The Window Tool Kit - 9 SEP 1996

Generated with Harlequin WebMaker