Silverfrost Logo About Us | Contact Us

Printer graphics

Here is a simple program that uses the standard call-back GPRINTER_OPEN to respond to a button press and draws a diagonal line across the entire page. GPRINTER_OPEN creates a drawing surface and an additional call-back argument is used to contain code to draw to this surface.

      INTEGER i,winio@
      EXTERNAL test
      INCLUDE <windows.ins>
      INTEGER xmax,ymax
      CALL get_graphical_resolution@(xmax,ymax)
      CALL draw_line_between@(0,0,xmax-1,ymax-1,15)

Notice that the call to get_graphical_resolution@ will work for all types of drawing surfaces. This means that the same code can be used to generate graphics output to the screen and to the printer.

Notice also that by default the drawing surface for the printer uses VGA rather than RGB mode. So in this example, the colour for draw_line_between@ is provided as a colour index (15 represents intense white in this program) rather than an RGB value. Normally RGB mode is preferred and this requires a prior call of use_rgb_colours@(0,.true.) (see the example in Using a metafile to print multiple copies).

By using open_printer@ etc., it is possible to have two drawing surfaces, one attached to the screen and the other to a graphics printer or plotter. In the following example one handle is attached to a %gr - Graphics Region region (a screen drawing surface) whilst a second handle is attached to a graphics printer drawing surface.

  INTEGER ctrl,hnd1,hnd2
  DATA hnd1,hnd2/1,2/
  CALL draw_line_between@(100,100,300,200,15)
  CALL draw_filled_ellipse@(200,150,75,50,2)

As usual, open_printer@ generates a standard "Open Printer" dialog box from which the user selects a graphics printer or plotter. Subsequent calls to ClearWin+ drawing routines are written to this drawing surface and the output is generated when the ClearWin+ routine close_printer@ or the routine new_page@ is called.


• open_printer@ etc. may be used independently of winio@.

• In the above example, j and k can be used to test for the success of the associated function calls.

• Printer surfaces will use GDI+ features if they are turned on.

PRINT_GRAPHICS@ will help manage printing.



Copyright © 1999-2018 Silverfrost Limited