home *** CD-ROM | disk | FTP | other *** search
- Fastjet
- Copyright © 1990 Charles Tyson
-
- Fastjet is `BegWare': use it all you want without feeling guilty. But
- if it brightens your day and brings new meaning to your life, why not
- reach in the closet, pull out one of those old games you haven't played
- in months, and mail it to me? I'd appreciate it!
-
- Fastjet is not `public domain', but may be `freely distributed'. All
- rights reserved. Subject to change without notice. Trespassers will
- be prosecuted.
-
- I can be reached online at:
-
- PLink (American Peoplelink) as C-M-T
- GEnie as C.Tyson
-
- or by mail sent to: Charles Tyson
- c/o SITIKE
- 1211 Mission Road
- South San Francisco, CA 94080
-
- ***********************************************************************
-
- Notes for version 1.00 -- May 7, 1990
-
- Description:
-
- Fastjet is a graphics compresser for the Hewlett-Packard Deskjet. It
- seems to work with the Deskjet Plus too, but since I don't own one, I
- can't speak with authority. It won't work with the Laserjet II (which
- doesn't know the Deskjet's "compressed graphics" commands). I have
- heard that the Laserjet IIP and III have a compressed graphics mode,
- but I don't know if it's the same as the Deskjet's.
-
- Most programs send a pixel-by-pixel image to the Deskjet. A full page
- image can require over 800,000 bytes of data to be sent. Fastjet uses
- the Deskjet's "compressed graphics" modes to reduce the amount of data
- that must be sent, which naturally saves time. It also saves disk
- space if the image is being stored for later reprinting.
-
- (Alas, you won't always save time by using Fastjet. When Fastjet is
- multitasking with a printing program, it necessarily slows down the
- other program by stealing CPU time from it. Also, the Deskjet takes a
- little longer to process compressed graphics. But if Fastjet can
- compress the data efficiently enough, the time saved by transmitting
- fewer bytes over the printer cable will outweigh the other factors.)
-
- Fastjet understands most of the codes (escape sequences) used by the
- Deskjet to create graphics. It is smart enough to pass through text
- and downloaded fonts, so you can send any type of file to the Deskjet
- via Fastjet.
-
- Fastjet was written primarily to work with Soft-Logik's Pagestream
- program. It should work with any graphics-printing programs that
- have a "print to disk" option. It is my understanding that
- Professional Page does not allow printing to disk. If you capture Pro
- Page's output with the CMD program, Fastjet can at least compress the
- saved file for later use.
-
- Files compressed by Fastjet are completely ordinary Deskjet files. No
- special steps have to be taken to send them to the printer--just
- TYPE >PAR: filename.
-
- For best results, you should use Fastjet in connection with the PIPE:
- device included in Workbench 1.3. PIPE: looks like a RAMdisk to
- programs that write to and read from it, but a file written to PIPE:
- isn't saved in memory or on a disk--it is just passed on to another
- program that has asked to read the same file. The end result, thanks
- to multitasking, is:
-
- You tell Fastjet to wait for input from PIPE:somefilename
- Your application sends uncompressed Deskjet graphics to
- PIPE:somefilename
- Fastjet compresses the graphics and sends them to PAR:
- The Deskjet receives the compressed data and prints it out.
-
- **********************************************************************
-
- Usage:
-
- Fastjet runs from CLI only.
-
- Syntax: [run] fastjet infile [outfile] [-c]
-
- 1. Infile (the file to read from) must be specified.
-
- 2. If outfile is not specified, Fastjet writes to PAR:. If you want to
- save Fastjet's output to a disk for later printing, specify the
- output filename. Note that if the output file already exists,
- Fastjet appends to it.
-
- 3. If -c is specified, Fastjet stays in memory until a Ctrl-C is sent
- to its CLI. This option should ONLY be used when infile is a PIPE:
- file, otherwise Fastjet may do VERY ugly things (like sending the
- input file to PAR: over and over)!
-
- If Fastjet is working on a file when the Ctrl-C is sent, it will
- shut down almost immediately. If Fastjet is waiting for a PIPE:
- file to appear, you must follow up the Ctrl-C by writing to the
- PIPE: file (with, e.g., an ECHO command--see below for an example).
- Fastjet will then exit with a harmless error message.
-
- When invoked with the -c option, Fastjet opens its output file
- only when it has work to do. Other programs can write to PAR:
- while Fastjet is "sleeping" in the background.
-
- **********************************************************************
-
- Test results:
-
- These results were obtained with a 2.5MB Amiga 1000 and a Deskjet with
- 128K expansion cartridge. The program tested was Pagestream 1.80.
- Pagestream and Fastjet were the only programs running.
-
- Fastjet was started with "run fastjet pipe:a"; Pagestream was printing
- to disk file "pipe:a".
-
- "Time" is the time (in minutes and seconds) from the start of the
- print job until the Deskjet ejected the page and reset itself. "Bytes
- sent" is the number of bytes output to PAR:, to give an idea of how
- effective compression can be.
-
- 1. Sending a blank page: not really a fair test, but fun to compare.
- It demonstrates Fastjet's optimization of vertical blank space.
-
- PgS alone w/ Fastjet Speedup
- Time 4:15 0:31 823%
- Bytes sent 19173 64
-
- 2. Sending a page with only a full-page vertical line along the right
- edge. Another unfair test to demonstrate Fastjet's optimization
- of blank space at the left margin.
-
- PgS alone w/ Fastjet Speedup
- Time 10:12 6:07 67%
- Bytes sent 797223 34271
-
- 3. Sending a complex, full page business form. A fair test.
-
- PgS alone w/ Fastjet Speedup
- DJ back 13:56 9:32 46%
- Bytes sent 788475 138387
-
- 4. Worst case: a crowded newsletter page with very little blank space
- and no regular black/white patterns (so compression is not very
- efficient).
-
- PgS alone w/ Fastjet Speedup
- DJ back 12:50 11:59 7%
- Bytes sent 646218 366132
-
- 5. Testing with other programs shows that Fastjet can, on the average,
- compress a graphics file to about 40% of its original size.
-
- The only program I know of that does its own compression is
- Printscript (now Pixelscript, but I don't have the updated version).
- Fastjet doesn't interfere with the Printscript's precompressed
- graphics, and can even save some disk space by stripping some
- unnecessary control codes that Printscript sends.
-
- **********************************************************************
-
- Walkthrough:
-
- This is a typical example of using Fastjet and Pagestream together
- via the PIPE: device. Comments are enclosed in parentheses.
-
- 1. From CLI:
-
- mount pipe:
- (Your mountlist must have an entry for pipe:, and the file )
- (Pipe-Handler must exist in your L: directory )
-
- run fastjet pipe:a -c
- (Note the number of the CLI that Fastjet runs in. You will )
- (need it later to send a break signal to Fastjet. )
-
- ("a" is the PIPE: filename that Pagestream will have to write )
- (to. You can substitute any other legal filename. )
-
- (If you don't include the "-c" option, Fastjet will exit after )
- (Pagestream's first print job. You could then restart Fastjet,)
- (but it's easier to enable "continuous" mode now. )
-
- 2. From Workbench:
-
- (Open your Pagestream drawer and start Pagestream by clicking )
- (on its icon. )
-
- 3. From Pagestream:
-
- (Select the "Configure Printer" option from the "Global" menu )
- (at the right end of the menu bar. The Printer Configuration )
- (box appears. On my copy, the Output Driver is "HP DeskJet )
- (beta". Below that, click on the "Send To ... Disk File" box. )
- (Click on the "OK" box. )
-
- (Load a Pagestream file and do whatever you want until your )
- (page is ready to print. Select the "Print" option from the )
- ("File" menu at the left end of the menu bar. Make any )
- (necessary settings in the Print Driver box that appears, then )
- (click on the "Print" box. )
-
- (A file requestor appears. Click on the "Drawer" box, delete )
- (anything already there with RightAmiga-X, type "pipe:", and )
- (press the return key. Click on the "File" box and type in )
- (the name of the PIPE: file that you used when starting )
- (Fastjet--in this example, "a". Then click on the "OK" box. )
-
- (With any luck, your page will start to emerge on the Deskjet. )
- (If it doesn't, move back to the Workbench screen and see if )
- (Fastjet has sent an error message. )
-
- (Continue working with and printing from Pagestream as long as )
- (you like. You don't have to do anything special before )
- (quitting Pagestream. )
-
- 4. From CLI:
-
- (Click on your CLI. If you've forgotten the number of )
- (Fastjet's CLI, enter the following command: )
-
- status
- (Fastjet will be one of the "Process Numbers" listed. For this)
- (example, I'll assume that Fastjet is process 3, or CLI 3. )
-
- break 3 c
- (This sends a break signal, specifically a Ctrl-C, to process )
- (number 3. The "3" is arbitrary, depending on Fastjet's CLI. )
- (The "c" is required. )
-
- echo >pipe:a
- (If Fastjet is waiting for a new job, it will ignore the Ctrl-C)
- (until the PIPE: device sends it some data--any data will do. )
- (This echo sends an end-of-file indicator through the pipe, )
- (which is good enough to end Fastjet. )
-
- **********************************************************************
-
- Deskjet Graphics Compression:
-
- If you're interested, this is how Deskjet compression works. The
- Deskjet receives graphic data one horizontal pixel-row at a time. Each
- byte of data determines whether the next eight pixels (dots) will be
- `on' or `off' (printed or left blank). At its highest setting, the
- Deskjet prints 300 dots per inch horizontally and vertically.
-
- Fastjet uses three methods for reducing the amount of data needed to
- describe a page.
-
- Vertical blank space: Most programs indicate a blank pixel-row by
- sending an ESC*b0W command--which means "all the pixels on this row are
- off." This command is sent for each empty row, and the Deskjet is
- surprisingly slow to interpret it. Fastjet intercepts the ESC*b0W
- commands, counts how many of them occur consecutively, and substitutes
- one command of the form ESC*p+nnnY. This means "move the printhead
- down nnn/300ths of an inch," and the Deskjet does this quickly.
- This technique saves about 1,500 bytes per inch of blank space (at 300
- dpi).
-
- Left margin offset: If there is any blank space at the left margin of
- a pixel-row, most programs send a long string of null (ASCII 0) bytes
- to indicate the pixels are `off'. Fastjet counts the null bytes at the
- beginning of each line and replaces them with an ESC*bnnnX command,
- which means "for this row, move right nnn pixels before printing
- anything." This saves about 10,000 bytes per square inch of blank
- space at the left margin.
-
- Data compression: In its default mode, each byte of graphic data
- represents exactly eight pixels. To print an 8-inch horizontal line
- at 300 dpi requires 300 bytes of data (8 inches times 300 pixels/inch
- divided by 8 pixels/byte). Fastjet uses the Deskjet's optional
- "compaction mode 2," in which data bytes are subdivided into `count'
- bytes and `real data' bytes. A `count' byte of -1 to -127 tells the
- Deskjet to read the next byte (a `real data' byte) and repeat it
- -(count-1) times. Thus the horizontal line, originally represented by
- 300 bytes with the value 255, would be replaced by six bytes: -127 255
- -127 255 -43 255. A `count' byte of 0 to 127 means "the next count+1
- bytes are dissimilar `real data' bytes; just print them as is."
-
- If your eyes glazed over during that last paragraph, the main point is
- that compression is very effective when there are sequences of repeated
- data bytes. If your image has long horizontal lines or horizontal
- blank spaces, it will compress well.
-
- **********************************************************************
-
- Thanks to J. Wolf for reminding me that PIPE: existed. Otherwise,
- Fastjet would have been "a good idea, but how do I make it work?"
-
- Fastjet was written with Lattice C 5.04. The compaction mode 2
- subroutine is in assembly language. After I win the lottery and retire
- to my country estate, I might rewrite the whole thing in assembler.
- Watch for it!
-