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.

COPY_GRAPHICS_REGION@

Copies from one designated surface to another.

CREATE_GRAPHICS_REGION@

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

DELETE_GRAPHICS_REGION@

Releases the memory for a drawing surface.

GRAPHICS_TO_CLIPBOARD@

Copies a surface to the clipboard.

SCROLL_GRAPHICS@

Scrolls a drawing surface.

SELECT_GRAPHICS_OBJECT@

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@.

      WINAPP
      IMPLICIT NONE
      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)
      width=2.0*clearwin_info@('SCREEN_WIDTH')/3.0
      depth=2.0*clearwin_info@('SCREEN_DEPTH')/3.0
      white=RGB@(255,255,255)
      i=winio@('%ww%ca[Off-Screen Regions]&')
      i=winio@('%mn[&Exit]&','EXIT')
      i=winio@('%lw&',ictrl)
      i=winio@('%`gr[black]',width,depth,g_handle)
      ierr=create_graphics_region@(r_handle,width,depth)
      ierr=select_graphics_object@(r_handle)
      hdib=import_bmp@('c:\windows\setup.bmp',ierr)
      ierr=dib_paint@(0,0,hdib,0,0)
      CALL release_screen_dib@(hdib)
      CALL draw_characters@('This was drawn off screen',
     +                 100,100,white)
      ierr=select_graphics_object@(g_handle)
      CALL draw_characters@('This was drawn to a window',
     +                 100,100,white)
      i=winio@('%bt[Show Off-Screen Block]')
      ierr=copy_graphics_region@(g_handle,0,0,width,depth,
     +                   r_handle,0,0,width,depth,SRCCOPY)
      END

 

 

Basket
Empty
 
Copyright © 1999-2024 Silverfrost Limited