Off-screen graphics

In this section:

Sometimes, it is useful to build up graphics information in memory, rather than on the screen. For example, such information might be subsequently copied to the screen at several locations, or written to a file. A complex drawing could be built up off screen whilst displaying other information. When complete, the drawing can be displayed.

In ClearWin+ there are two approaches to this issue each with its own set of routines. The first creates an internal drawing surface using CREATE_GRAPHICS_REGION@ and is described below. The other approach uses what is called a virtual screen and is described in the ClearWin+ User's Supplement. Mixing routines from the two sets may not produce the desired result.

An internal drawing surface uses the following set of routines together with the DIB routines listed in the section in Drawing device independent bitmaps.


Copies from one designated surface to another.


Creates a drawing surface of a given size. Use NEW_GRAPHICS_REGION@ to also specify the size.


Releases the memory for a drawing surface.


Copies a surface to the clipboard.


Scrolls a drawing surface.


Selects an existing drawing surface.

Here is a short program that creates a drawing surface using CREATE_GRAPHICS_REGION@, selects the surface by using SELECT_GRAPHICS_OBJECT@ copies a bitmap and writes a message into it. The current screen area is then selected by another call to SELECT_GRAPHICS_OBJECT@ allowing subsequent graphics drawing to be directed to the screen. When a button is clicked the internal surface is copied to the screen using COPY_GRAPHICS_REGION@.

      INCLUDE <windows.ins>
      INTEGER i,ictrl,width,depth,ierr,hdib
      INTEGER g_handle,r_handle,white
      PARAMETER (g_handle=7,r_handle=8)
      CALL set_rgb_colours_default@(1)
      i=winio@('%ww%ca[Off-Screen Regions]&')
      CALL release_screen_dib@(hdib)
      CALL draw_characters@('This was drawn off screen',
     +                 100,100,white)
      CALL draw_characters@('This was drawn to a window',
     +                 100,100,white)
      i=winio@('%bt[Show Off-Screen Block]')
     +                   r_handle,0,0,width,depth,SRCCOPY)



Copyright © 1999-2023 Silverfrost Limited