  ________________________________________________________________________
 /									  \
| ALLIANCE Presents : Amiga Graphics Inside and Out.		           |
|		      The complete Book from Abacus.			   |
|								           |
| Typed By          : Glitch.    					   |
| Supplied By       : Viper.						   |
| 									   |
| ALLIANCE ARE : Alchemist, Aramis, Barbarian, CI/\RS, Chaos, Glitch, Mit, |
|		 Raistlin, Razor Blade, ShadowFax and Viper.	           |
|								           |
 \________________________________________________________________________/


/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\
>									  <
>       CALL OUR WORLD HQ N-O-W : UNKNOWN PLEASURES : +44 823 322891	  <
>									  <
\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//\//


---------------------------------------------------------------------------


6.2 Hardcopies: enlarging and shrinking

The previous program creates hard copies that are suitable for most users
needs. However, we have barely utilised the capabilities of the printer
device. The following hardcopy routine enables you to print a section of a
window. When this section is sent to the printer, it can either be as
large as the window or it can reduced or enlarged.

The ¶ characters in the following program signify the end of a BASIC
program line. Some lines were split when the program was formatted for
this book.

	"####################################################¶
	"#¶
        "# Section:  6.2¶
        "# Program:  Hardcopy II¶
        "# Date:     11/2/92¶
        "# Author:   tob¶
        "# Version:  1.0¶
	"#¶
	"####################################################¶
 	¶
	"Allows you to print any section of a window¶
        "and enlarge or shrink the printed output"¶
	¶
        PRINT" Searching for .bamp file..."¶
	¶
        "EXEC-library¶
        DECLARE FUNCTION AlloMem& LIBRARY¶
	DECLARE FUNCTION DoIO% LIBRARY¶
	DECLARE FUNCTION OpenDevice% LIBRARY¶
	DECLARE FUNCTION AllocSignal% LIBRARY¶
	DECLARE FUNCTION FindTask& LIBRARY¶
        "FreeMem()¶
        "CloseDevice()¶
        "FreeSignal()¶
        "AddPort()¶
        "RemPort()¶
        ¶
        LIBRARY "exec.library"¶
        ¶
        init:   "* draw something¶
                CLS¶
                CIRCLE (300,100),100¶
                LINE (10,10)-(200,100),2,bf¶
                ¶
                "* Colors: black and white contrast¶
                PALETTE 0,1,1,1¶
                PALETTE 1,0,0,0¶


                                PAGE 265

-----------------------------------------------------------------------------



                ParameterHardcopy 200,10,200,100,1.2,.5¶
                ¶
                END¶
                ¶
      	SUB ParameterHardcopy(x%,y%,p.width%,p.height%,f1,f2)
        STATIC¶
                mem.opt&    = 2^0+2^16¶
                p.io&       = Allocmem&(100,mem.opt&)¶
                p.port      = .pio&+62¶
                IF p.io&    = 0 TEHN ERROR 7¶
                
       ¶
                f.windo&    = WINDOW(7)¶
                f.rastport& = PEEKL(f.windo&+50)¶
                f.width%    = PEEKW(f.windo&+112)¶
                f.height%   = PEEKW(f.windo&+114)¶
                f.screen&   = PEEKL(f.windo&+46)¶
                f.viewport& = f.screen&+44¶
                f.colormap& = PEEKL(f.veiwport&+4)¶
                f.vp.mode%  = PEEKW(f.viewport&+32)¶
                ¶
                ¶
                p.sigbit    = AllocSiganal%(-1)¶
                IF p.sigbit%= p.io -1 THEN
                   PRINT "No Signalbit Free!"¶
                   CALL FreeMem(p.io&100)¶
                   EXIT SUB¶
                END IF¶
                p.sigTask&  = FindTask&(0)¶
                ¶
                POKE  p.port&+8,5¶
                POKEL p.port&+10,p.port&+34¶
                POKE  p.port&+15,p.sigbit%
                POKEL p.port&+16,p.sigtask&¶
                POKE  p.port&+20,p.port&+24¶
                POKEL p.port&+28,p.port&+20¶
                POKE  p.port&+34,ASC("P")¶
                POKE  p.port&+35,ASC("R")¶
                POKE  p.port&+36,ASC("T")¶
                ¶
                CALL AddPort (p.port&)¶
                ¶
                POKE  p.io&+8,5¶
                POKEL p.io&+14,p.port&¶
                POKEW p.io&+28,11¶
                POKEL p.io&+32,f.RastPort&¶
                POKEL p.io&+36,f.colormap&¶
                POKEL p.io&+40,f.vp.mpde%¶
                POKEW p.io&+44,x
                POKEW p.io&+46,y
                POKEW p.io&+48,p.width¶
                POKEW p.io&+52,p.height¶
                POKEL p.io&+50,p.width%*f1
                POKEL p.io&+52,p.height%*f2
                
       ¶
                d.names$ = "printer.device+CHR$(0)¶
                status%  = OpenDevice$(SADD(d.na.mes),0,p.io&,0)¶
               

                                PAGE 266

----------------------------------------------------------------------------


                   IF status%<>0 THEN¶
                   PRINT"Pinter is not free."¶
                   CALL FreeMem(p.io&,100)¶
                   CALL FreeSignal(p.sigbit%)¶
                EXIT SUB
                ¶
                ercond% = DoIO%(p.io&)¶
                ¶
                CALL CloseDevice(p.io&)¶
                CALL RemPort(p.port&)¶
                CALL FreeMem(p.io&,100)¶
                CALL FreeSignal(.psigBit%)¶
                PRINT"Error Code: ";ercond%¶
                END SUB¶
 
Call:           ParameterHardcopy x%,y%,width%,height%,f1,f2
              
                x%,y%:   Coordinates of the upper left hand corner of the 
                         window peice you want to print.
                width%:  Width of the section in pixels.
                height%: Height of the section in pixels.
                f1:      Enlargement factor horizontal.
                f2:      Enlargement factor vertical.



                                PAGE 267

----------------------------------------------------------------------------
