info-mac@uw-beaver (01/11/85)
From: Charlie C. Kim <US.CCK%CU20B@COLUMBIA.ARPA> Following the dotted line below is a version of Ed Patterman's MACIMP program modified for the HP LaserJet. There are many enhancements which could be made (and some are listed in the program), but briefly, you can print at any of the four resolutions graphics resolutions (75, 100, 150, and 300 dots per inch). In addition, you can dump the Macpaint file directly to LaserJet if it is hooked up via a RS232 line. The output from the LaserJet, which uses the Canon LBP-CX engine, looks very crisp. The code, as written, is restricted to Decsystem-20's. For anyone who is thinking of converting the C version of MACIMP for the LaserJet, be warned that the LaserJet requires an eight bit data path with XON-XOFF. See the list Laser Lovers for more info on hooking a LaserJet to a Unix machine. No further support of this program by this author is anticipated: we only have the LaserJet on demo and it's leaving tomorrow. Charlie C. Kim Columbia University Center for Computing Activies User Services [An FTPable executable is in CU20B::PS:<MACINTOSH>MACHP.EXE] [The <info-mac> copy of the source is in MACHP.C -jma ]
info-mac@uw-beaver (01/18/85)
From: John Mark Agosta <INFO-MAC-REQUEST@SUMEX-AIM.ARPA> 10-Jan-85 04:21:59-PST,8883;000000000001 Return-Path: <US.CCK%CU20B@COLUMBIA.ARPA> Received: from columbia.arpa by SUMEX-AIM.ARPA with TCP; Thu 10 Jan 85 04:21:36-PST Received: from CU20B.ARPA by columbia.arpa; Thu, 10 Jan 85 07:23:09 est Date: Thu 10 Jan 85 07:21:49-EST From: Charlie C. Kim <US.CCK%CU20B@COLUMBIA.ARPA> Subject: Macpaint => LaserJet To: info-mac@SUMEX-AIM.ARPA Following the dotted line below is a version of Ed Patterman's MACIMP program modified for the HP LaserJet. There are many enhancements which could be made (and some are listed in the program), but briefly, you can print at any of the four resolutions graphics resolutions (75, 100, 150, and 300 dots per inch). In addition, you can dump the Macpaint file directly to LaserJet if it is hooked up via a RS232 line. The output from the LaserJet, which uses the Canon LBP-CX engine, looks very crisp. The code, as written, is restricted to Decsystem-20's. For anyone who is thinking of converting the C version of MACIMP for the LaserJet, be warned that the LaserJet requires an eight bit data path with XON-XOFF. See the list Laser Lovers for more info on hooking a LaserJet to a Unix machine. No further support of this program by this author is anticipated: we only have the LaserJet on demo and it's leaving tomorrow. Charlie C. Kim Columbia University Center for Computing Activies User Services [To the Editor: an FTPable executable is in CU20B::PS:<MACINTOSH>MACHP.EXE] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PROGRAM Machp ; (* This program converts a Macintosh bitmap file into a form ready to print on a HP LaserJet. It is a derivative of MACimp. As MACimp, MacHp has been proven to work with: o MACPAINT files o Screen dumps (created with COMMAND-SHIFT-3) It will not work with MACwrite files. Macimp was Written by Ed Pattermann (PATTERMANN@SUMEX), SUMEX Computer Project Copyright 1984 @ Stanford University Macimp was Rewritten for the HP LaserJet (mostly a matter of stripping) by Charlie C. Kim, Columbia University, January, 1985. *************************************************************** Much of the following comes directly from the original with obvious changes: MAChp converts a Macintosh bitmap file into a HP LaserJet file. It is also capable of driving the LaserJet directly (just specify the terminal number). The crux of this program is understanding the format of the Macintosh bitmap file. First, the Macintosh file ; This format is the common interchange format for full-page bitmap images on the Macintosh. The first 512 bytes of the file are the header. The first four bytes comprise the version number, followed by 38*8 = 304 bytes of patterns. The remaining 204 bytes of the header are reserved for future expansion. If the version number is zero, the patterns are ignored. Hence, programs that wish to create files to be read into MACpaint can just write out 512 bytes of zero as the header. Following the header are 720 compressed scanlines of data which form the 576 wide by 720 tall bitmap. The bitmap is compressed as follows ; Any run of three or more equal bytes is compressed into a count byte and a single data byte. Runs of unequal bytes are passed on literally, preceded also by a count byte. i.e. <count byte> <data byte> count = -1..-127 --> replicate byte 2..128 times <count byte> <n data bytes> count = 0.. 127 --> copy 1..128 bytes uncompressed count = -128 ignored for backward compatibility The format used by the HP LaserJet for graphics is simple. You must setup graphics with the following commands: <escape> * t # R <escape> * r # A where # is replaced by some number. The first command sets the resolution of the machine in dots per inch. The only legal values are 75, 100, 150, and 300. The second command defines the offset from the right margin. Each scan line must be prefixed by the following graphics transfer command: <escape> * b # W where the # specifies the number of following bytes. The interpretation of the bytes is: bit on - print black, bit off - do nothing. The bits are order high order to low order and all 8 bits of a byte are used. Graphics mode is terminated by the command: <escape> * r B and from this point on text may be printed. Reset commands (<escape> E) are used to ensure that the previous page is cleared out and the current page is printed respectively. (Note, the preceeding reset command has no effect during a graphics transfer command.) Things for someone to do: 1) Indent margins differently for different resolutions 2) Provide support for Landscape mode 3) Fix things so you can output to a file without resets: thus allowing someone to include a picture in a document. The reason the resets are retained is to allow direct spooling to the HP LaserJet. *) include 'pas:pascmd.pas'; include 'pas:csl.pas'; include 'pas:extern.pas'; Const esc = 27; VAR (* VARIABLES *) i,j,k,l : integer ; bytes : integer ; opcode : integer ; dpi : Integer; databyte : char; (* COMMAND TABLE FOR PARSING MAGNIFICATION FACTORS *) magtbl : table ; (* FOR PARSING TOPS20 FILES *) macjfn : integer ; outjfn : integer ; impjfn : integer ; inlength : integer ; infilename : PACKED ARRAY [1..80] OF char ; outfilename : PACKED ARRAY [1..80] OF char ; macfile : FILE OF char ; impfile : FILE OF char ; BEGIN magtbl := tbmak(4) ; tbadd(magtbl,1,'100 ',0); tbadd(magtbl,2,'150 ',0); tbadd(magtbl,3,'300 ',0); tbadd(magtbl,0,'75 ',0); Writeln(tty,'MAChp - A Macintosh bitmap file to LaserJet conversion program') ; cmini('Macintosh filename to be converted > '); cmhlp('Name of Macintosh file ') ; cmifi(macfile) ; inlength := cmatom(infilename) ; cmcfm ; cmini('Output file name > ') ; cmhlp('Enter local file name') ; gjgen(400000000000B) ; gjext('hp') ; cmdef('hp:'); { logical name pointing to printer } { port } cmfil(impfile) ; i := cmatom(outfilename) ; cmcfm ; cmini('Enter magnification desired [75,100,150,300; best = 75] > ') ; cmdef('75') ; { if its the best... } j := cmkey(magtbl) ; cmcfm; (* ADJUST TOP AND LEFT MARGINS DEPENDING on resolution *) (* should be done! *) CASE j OF 0: dpi := 75; 1: dpi := 100; 2: dpi := 150; 3: dpi := 300; END ; (* INITIALIZE INPUT FILE *) Reset(macfile,infilename,'/B:08') ; macjfn := curjfn(macfile) ; macjfn := rh(macjfn) ; (* INITIALIZE OUTPUT FILE *) Rewrite(impfile,outfilename,'/B:08') ; impjfn := curjfn(impfile) ; impjfn := rh(impjfn) ; (* WRITE OUR DOCUMENT HEADER AND INITIAL IMPRESS COMMANDS *) { Reset printer, set printer resolution, set left margin } Write(impfile,chr(esc),'E',chr(esc),'*t',dpi:0,'R',chr(esc),'*r0A'); (* READ IN HEADER *) { This allows `piped' output, so it gets left alone instead of being } { changed to a sfptr... } FOR i := 1 TO 512 DO jsys(bin,1; macjfn ; j,databyte) ; (* READ IN DATA BYTES *) Writeln(tty,'Processing ',infilename:inlength,' ') ; FOR i := 1 TO 720 DO BEGIN if i mod 20 = 0 then write(tty,'.'); { let's see what's going on } write(impfile,chr(esc),'*b72W'); WHILE bytes < 72 DO BEGIN jsys(bin,1; macjfn ; j,opcode) ; IF opcode > 127 THEN BEGIN opcode := 256-opcode+1 ; jsys(bin,1; macjfn ; j,databyte) ; FOR l := 1 TO opcode DO BEGIN impfile^:=databyte; put(impfile); END ; END ELSE BEGIN opcode := opcode + 1 ; FOR l := 1 TO opcode DO BEGIN jsys(bin,1; macjfn ; j,databyte) ; impfile^:=databyte; put(impfile); END ; END; bytes := bytes + opcode ; END; (* WHILE BYTES < 72 *) IF bytes > 72 THEN BEGIN Writeln(tty,'[FAILED]') ; Writeln(tty,'Input file is not a macintosh bitmap file') ; close(macfile) ; jsys(haltf) ; END ; bytes := 0 ; END; (* FOR I := 1 TO 720 *) (* WRITE OUT ENDING HP COMMANDS *) write(impfile,chr(esc),'*rB',chr(esc),'E'); { end graphics mode and reset } (* WERE DONE *) close(impfile) ; close(macfile) ; Writeln(tty,'[OK]') END. ------- --------------- Mail-From: INFO-MAC-REQUEST created at 10-Jan-85 21:43:53 Return-Path: <US.CCK%CU20B@COLUMBIA.ARPA> Received: from columbia.arpa by SUMEX-AIM.ARPA with TCP; Thu 10 Jan 85 04:21:36-PST Received: from CU20B.ARPA by columbia.arpa; Thu, 10 Jan 85 07:23:09 est Date: Thu 10 Jan 85 07:21:49-EST From: Charlie C. Kim <US.CCK%CU20B@COLUMBIA.ARPA> Subject: Macpaint => LaserJet To: info-mac@SUMEX-AIM.ARPA ReSent-date: Thu 10 Jan 85 21:43:53-PST ReSent-From: John Mark Agosta <INFO-MAC-REQUEST@SUMEX-AIM.ARPA> ReSent-To: info-mac: ; Following the dotted line below is a version of Ed Patterman's MACIMP program modified for the HP LaserJet. There are many enhancements which could be made (and some are listed in the program), but briefly, you can print at any of the four resolutions graphics resolutions (75, 100, 150, and 300 dots per inch). In addition, you can dump the Macpaint file directly to LaserJet if it is hooked up via a RS232 line. The output from the LaserJet, which uses the Canon LBP-CX engine, looks very crisp. The code, as written, is restricted to Decsystem-20's. For anyone who is thinking of converting the C version of MACIMP for the LaserJet, be warned that the LaserJet requires an eight bit data path with XON-XOFF. See the list Laser Lovers for more info on hooking a LaserJet to a Unix machine. No further support of this program by this author is anticipated: we only have the LaserJet on demo and it's leaving tomorrow. Charlie C. Kim Columbia University Center for Computing Activies User Services [An FTPable executable is in CU20B::PS:<MACINTOSH>MACHP.EXE] [The <info-mac> copy of the source is in MACHP.C -jma ] -------