Using a metafile to print multiple copies

In this section:

Here is another sample program which (like the above example) shows how to draw to a screen drawing surface in parallel with output to a graphics printer or plotter. In this case the image is scaled according to which device is used. Multiple copies are printed by calling DO_COPIES@ but this routine requires a metafile recording of the current image before it is called.

      INCLUDE <windows.ins>
      REAL scaling
      INTEGER i,wc,res,ncopies
      INTEGER screen_height,printer_height
      INTEGER screen_width,printer_width
      INTEGER screen_id,printer_id
      EXTERNAL graphics
      COMMON scaling,screen_id,printer_id
      CALL set_rgb_colours_default@(1)
      scaling=1.0
c---  Give id numbers to the screen and printer
      screen_id=1
      printer_id=2
c---
      i=winio@('%ww%ca[Salford graphics]&')
      i=winio@('%`gr[black]&',640,480,screen_id)
      i=winio@('%`bt[OK]%lw',wc)
      CALL graphics()
      CALL get_graphical_resolution@(screen_width,
     +          screen_height)
c---  Select printer and start document
      res=open_printer@(printer_id)
      IF(res.NE.0)THEN
        CALL use_rgb_colours@(printer_id,.true.)
        CALL get_graphical_resolution@(printer_width,
     +                                 printer_height)
c---    Scaling factor for printer
        scaling=printer_width/screen_width
c---    Open metafile to record printer drawing
        CALL open_metafile@(printer_id)
        CALL graphics()
c---    Stop recording
        CALL close_metafile@(printer_id)
c---    Make copies of the page
        ncopies=2
        CALL do_copies@(printer_id,ncopies)
c---    Print document
        res=close_printer@(printer_id)
        CALL select_graphics_object@(screen_id)
        scaling=1.0
      ENDIF
      END

      SUBROUTINE graphics()
      INCLUDE <windows.ins>
      INTEGER x(10),y(10)
      INTEGER hpol,z,xa,xb,err
      REAL scaling
      INTEGER screen_id,printer_id
      COMMON scaling,screen_id,printer_id
      CALL set_line_width@(3)
c---  Select font
      CALL set_text_attribute@(101,3*scaling,0,0)
      xa=300*scaling
      xb=350*scaling
      CALL draw_characters@('HELLO',xa,xb,RGB@(255,255,255))
      CALL set_line_width@(1)
      z=200*scaling
      CALL draw_line_between@(0,0,z,z,RGB@(255,0,0))
      CALL draw_line_between@(0,z,z,0,RGB@(0,255,0))
c---  Ellipse
      z=100*scaling
      xa=80*scaling
      xb=40*scaling
      CALL draw_ellipse@(z,z,xa,xb,RGB@(255,0,0))
      xa=60*scaling
      CALL draw_filled_ellipse@(z,z,xa,xb,RGB@(0,0,255))
c---  Polyline
      x(1)=230*scaling
      y(1)=20*scaling
c---  .... Code for x(2..4) and y(2..4)
      x(5)=x(1)
      y(5)=y(1)
      CALL draw_polyline@(x,y,5,RGB@(255,0,0))
c---  Polygon
      x(1)=30*scaling
      y(1)=250*scaling
c---  .... Code for x(2..4) and y(2..4)
      x(5)=30*scaling
      y(5)=250*scaling
      CALL draw_filled_polygon@(x,y,5,RGB@(255,0,0))
      END

 

 

Basket
Empty
 
Copyright © 1999-2024 Silverfrost Limited