home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 384.lha / Fastjet_v1.0 / Fastjet.doc < prev    next >
Encoding:
Text File  |  1990-06-11  |  12.8 KB  |  296 lines

  1. Fastjet 
  2. Copyright © 1990 Charles Tyson
  3.  
  4. Fastjet is `BegWare':  use it all you want without feeling guilty.  But
  5. if it brightens your day and brings new meaning to your life, why not
  6. reach in the closet, pull out one of those old games you haven't played
  7. in months, and mail it to me?  I'd appreciate it!
  8.  
  9. Fastjet is not `public domain', but may be `freely distributed'.  All
  10. rights reserved.  Subject to change without notice.  Trespassers will
  11. be prosecuted.
  12.  
  13. I can be reached online at:
  14.  
  15. PLink (American Peoplelink) as C-M-T
  16. GEnie                       as C.Tyson
  17.  
  18. or by mail sent to:         Charles Tyson
  19.                             c/o SITIKE
  20.                             1211 Mission Road
  21.                             South San Francisco, CA  94080
  22.  
  23. ***********************************************************************
  24.  
  25. Notes for version 1.00 -- May 7, 1990
  26.  
  27. Description:
  28.  
  29. Fastjet is a graphics compresser for the Hewlett-Packard Deskjet.  It
  30. seems to work with the Deskjet Plus too, but since I don't own one, I
  31. can't speak with authority.  It won't work with the Laserjet II (which
  32. doesn't know the Deskjet's "compressed graphics" commands).  I have
  33. heard that the Laserjet IIP and III have a compressed graphics mode,
  34. but I don't know if it's the same as the Deskjet's.
  35.  
  36. Most programs send a pixel-by-pixel image to the Deskjet.  A full page
  37. image can require over 800,000 bytes of data to be sent.  Fastjet uses
  38. the Deskjet's "compressed graphics" modes to reduce the amount of data
  39. that must be sent, which naturally saves time.  It also saves disk
  40. space if the image is being stored for later reprinting.
  41.  
  42. (Alas, you won't always save time by using Fastjet.  When Fastjet is
  43. multitasking with a printing program, it necessarily slows down the
  44. other program by stealing CPU time from it.  Also, the Deskjet takes a
  45. little longer to process compressed graphics.  But if Fastjet can
  46. compress the data efficiently enough, the time saved by transmitting
  47. fewer bytes over the printer cable will outweigh the other factors.)
  48.  
  49. Fastjet understands most of the codes (escape sequences) used by the 
  50. Deskjet to create graphics.  It is smart enough to pass through text
  51. and downloaded fonts, so you can send any type of file to the Deskjet
  52. via Fastjet.
  53.  
  54. Fastjet was written primarily to work with Soft-Logik's Pagestream
  55. program.  It should work with any graphics-printing programs that
  56. have a "print to disk" option.  It is my understanding that
  57. Professional Page does not allow printing to disk.  If you capture Pro
  58. Page's output with the CMD program, Fastjet can at least compress the
  59. saved file for later use.
  60.  
  61. Files compressed by Fastjet are completely ordinary Deskjet files.  No
  62. special steps have to be taken to send them to the printer--just
  63. TYPE >PAR: filename.
  64.  
  65. For best results, you should use Fastjet in connection with the PIPE: 
  66. device included in Workbench 1.3.  PIPE: looks like a RAMdisk to 
  67. programs that write to and read from it, but a file written to PIPE:
  68. isn't saved in memory or on a disk--it is just passed on to another
  69. program that has asked to read the same file.  The end result, thanks
  70. to multitasking, is:
  71.  
  72.   You tell Fastjet to wait for input from PIPE:somefilename
  73.   Your application sends uncompressed Deskjet graphics to 
  74.   PIPE:somefilename
  75.   Fastjet compresses the graphics and sends them to PAR:
  76.   The Deskjet receives the compressed data and prints it out.
  77.  
  78. **********************************************************************
  79.  
  80. Usage:
  81.  
  82. Fastjet runs from CLI only.
  83.  
  84. Syntax:  [run] fastjet infile [outfile] [-c]
  85.  
  86. 1. Infile (the file to read from) must be specified. 
  87.  
  88. 2. If outfile is not specified, Fastjet writes to PAR:.  If you want to
  89.    save Fastjet's output to a disk for later printing, specify the
  90.    output filename.  Note that if the output file already exists,
  91.    Fastjet appends to it.
  92.  
  93. 3. If -c is specified, Fastjet stays in memory until a Ctrl-C is sent
  94.    to its CLI.  This option should ONLY be used when infile is a PIPE:
  95.    file, otherwise Fastjet may do VERY ugly things (like sending the
  96.    input file to PAR: over and over)!
  97.  
  98.    If Fastjet is working on a file when the Ctrl-C is sent, it will
  99.    shut down almost immediately.  If Fastjet is waiting for a PIPE:
  100.    file to appear, you must follow up the Ctrl-C by writing to the
  101.    PIPE: file (with, e.g., an ECHO command--see below for an example).
  102.    Fastjet will then exit with a harmless error message.
  103.  
  104.    When invoked with the -c option, Fastjet opens its output file
  105.    only when it has work to do.  Other programs can write to PAR:
  106.    while Fastjet is "sleeping" in the background.
  107.  
  108. **********************************************************************
  109.  
  110. Test results:
  111.  
  112. These results were obtained with a 2.5MB Amiga 1000 and a Deskjet with
  113. 128K expansion cartridge.  The program tested was Pagestream 1.80.
  114. Pagestream and Fastjet were the only programs running.
  115.  
  116. Fastjet was started with "run fastjet pipe:a"; Pagestream was printing
  117. to disk file "pipe:a".
  118.  
  119. "Time" is the time (in minutes and seconds) from the start of the
  120. print job until the Deskjet ejected the page and reset itself. "Bytes
  121. sent" is the number of bytes output to PAR:, to give an idea of how
  122. effective compression can be.
  123.  
  124. 1. Sending a blank page:  not really a fair test, but fun to compare.
  125.    It demonstrates Fastjet's optimization of vertical blank space.
  126.  
  127.                      PgS alone      w/ Fastjet      Speedup
  128.    Time                 4:15            0:31          823%
  129.    Bytes sent          19173              64
  130.  
  131. 2. Sending a page with only a full-page vertical line along the right
  132.    edge.  Another unfair test to demonstrate Fastjet's optimization
  133.    of blank space at the left margin.
  134.  
  135.                      PgS alone      w/ Fastjet      Speedup
  136.    Time                10:12            6:07           67%
  137.    Bytes sent         797223           34271
  138.  
  139. 3. Sending a complex, full page business form.  A fair test.
  140.  
  141.                      PgS alone      w/ Fastjet      Speedup
  142.    DJ back             13:56            9:32           46%
  143.    Bytes sent         788475          138387
  144.  
  145. 4. Worst case:  a crowded newsletter page with very little blank space
  146.    and no regular black/white patterns (so compression is not very
  147.    efficient).
  148.  
  149.                      PgS alone      w/ Fastjet      Speedup
  150.    DJ back             12:50           11:59            7%
  151.    Bytes sent         646218          366132
  152.  
  153. 5. Testing with other programs shows that Fastjet can, on the average,
  154.    compress a graphics file to about 40% of its original size.
  155.  
  156.    The only program I know of that does its own compression is
  157.    Printscript (now Pixelscript, but I don't have the updated version).
  158.    Fastjet doesn't interfere with the Printscript's precompressed 
  159.    graphics, and can even save some disk space by stripping some
  160.    unnecessary control codes that Printscript sends.
  161.  
  162. **********************************************************************
  163.  
  164. Walkthrough:
  165.  
  166. This is a typical example of using Fastjet and Pagestream together
  167. via the PIPE: device.  Comments are enclosed in parentheses.
  168.  
  169. 1. From CLI:
  170.  
  171.    mount pipe:
  172.    (Your mountlist must have an entry for pipe:, and the file     )
  173.    (Pipe-Handler must exist in your L: directory                  )
  174.  
  175.    run fastjet pipe:a -c
  176.    (Note the number of the CLI that Fastjet runs in.  You will    )
  177.    (need it later to send a break signal to Fastjet.              )
  178.  
  179.    ("a" is the PIPE: filename that Pagestream will have to write  )
  180.    (to.  You can substitute any other legal filename.             )
  181.  
  182.    (If you don't include the "-c" option, Fastjet will exit after )
  183.    (Pagestream's first print job.  You could then restart Fastjet,)
  184.    (but it's easier to enable "continuous" mode now.              )
  185.  
  186. 2. From Workbench:
  187.  
  188.    (Open your Pagestream drawer and start Pagestream by clicking  )
  189.    (on its icon.                                                  )
  190.  
  191. 3. From Pagestream:
  192.  
  193.    (Select the "Configure Printer" option from the "Global" menu  )
  194.    (at the right end of the menu bar.  The Printer Configuration  )
  195.    (box appears.  On my copy, the Output Driver is "HP DeskJet    )
  196.    (beta".  Below that, click on the "Send To ... Disk File" box. )
  197.    (Click on the "OK" box.                                        )
  198.  
  199.    (Load a Pagestream file and do whatever you want until your    )
  200.    (page is ready to print.  Select the "Print" option from the   )
  201.    ("File" menu at the left end of the menu bar.  Make any        )
  202.    (necessary settings in the Print Driver box that appears, then )
  203.    (click on the "Print" box.                                     )
  204.  
  205.    (A file requestor appears.  Click on the "Drawer" box, delete  )
  206.    (anything already there with RightAmiga-X, type "pipe:", and   )
  207.    (press the return key.  Click on the "File" box and type in    )
  208.    (the name of the PIPE: file that you used when starting        )
  209.    (Fastjet--in this example, "a".  Then click on the "OK" box.   )
  210.  
  211.    (With any luck, your page will start to emerge on the Deskjet. )
  212.    (If it doesn't, move back to the Workbench screen and see if   )
  213.    (Fastjet has sent an error message.                            )
  214.  
  215.    (Continue working with and printing from Pagestream as long as )
  216.    (you like.  You don't have to do anything special before       )
  217.    (quitting Pagestream.                                          )
  218.  
  219. 4. From CLI:
  220.  
  221.    (Click on your CLI.  If you've forgotten the number of         )
  222.    (Fastjet's CLI, enter the following command:                   )
  223.  
  224.    status
  225.    (Fastjet will be one of the "Process Numbers" listed.  For this)
  226.    (example, I'll assume that Fastjet is process 3, or CLI 3.     )
  227.  
  228.    break 3 c
  229.    (This sends a break signal, specifically a Ctrl-C, to process  )
  230.    (number 3.  The "3" is arbitrary, depending on Fastjet's CLI.  )
  231.    (The "c" is required.                                          )
  232.  
  233.    echo >pipe:a
  234.    (If Fastjet is waiting for a new job, it will ignore the Ctrl-C)
  235.    (until the PIPE: device sends it some data--any data will do.  )
  236.    (This echo sends an end-of-file indicator through the pipe,    )
  237.    (which is good enough to end Fastjet.                          )
  238.  
  239. **********************************************************************
  240.  
  241. Deskjet Graphics Compression:
  242.  
  243. If you're interested, this is how Deskjet compression works.  The
  244. Deskjet receives graphic data one horizontal pixel-row at a time.  Each
  245. byte of data determines whether the next eight pixels (dots) will be
  246. `on' or `off' (printed or left blank).  At its highest setting, the
  247. Deskjet prints 300 dots per inch horizontally and vertically.
  248.  
  249. Fastjet uses three methods for reducing the amount of data needed to
  250. describe a page.
  251.  
  252. Vertical blank space:  Most programs indicate a blank pixel-row by
  253. sending an ESC*b0W command--which means "all the pixels on this row are
  254. off."  This command is sent for each empty row, and the Deskjet is
  255. surprisingly slow to interpret it.  Fastjet intercepts the ESC*b0W
  256. commands, counts how many of them occur consecutively, and substitutes
  257. one command of the form ESC*p+nnnY.  This means "move the printhead
  258. down nnn/300ths of an inch," and the Deskjet does this quickly.
  259. This technique saves about 1,500 bytes per inch of blank space (at 300
  260. dpi).
  261.  
  262. Left margin offset:  If there is any blank space at the left margin of
  263. a pixel-row, most programs send a long string of null (ASCII 0) bytes
  264. to indicate the pixels are `off'.  Fastjet counts the null bytes at the
  265. beginning of each line and replaces them with an ESC*bnnnX command,
  266. which means "for this row, move right nnn pixels before printing
  267. anything."  This saves about 10,000 bytes per square inch of blank
  268. space at the left margin.
  269.  
  270. Data compression:  In its default mode, each byte of graphic data
  271. represents exactly eight pixels.  To print an 8-inch horizontal line
  272. at 300 dpi requires 300 bytes of data (8 inches times 300 pixels/inch
  273. divided by 8 pixels/byte).  Fastjet uses the Deskjet's optional 
  274. "compaction mode 2," in which data bytes are subdivided into `count'
  275. bytes and `real data' bytes.  A `count' byte of -1 to -127 tells the
  276. Deskjet to read the next byte (a `real data' byte) and repeat it
  277. -(count-1) times.  Thus the horizontal line, originally represented by
  278. 300 bytes with the value 255, would be replaced by six bytes: -127 255
  279. -127 255 -43 255.  A `count' byte of 0 to 127 means "the next count+1
  280. bytes are dissimilar `real data' bytes; just print them as is."
  281.  
  282. If your eyes glazed over during that last paragraph, the main point is
  283. that compression is very effective when there are sequences of repeated
  284. data bytes.  If your image has long horizontal lines or horizontal
  285. blank spaces, it will compress well.
  286.  
  287. **********************************************************************
  288.  
  289. Thanks to J. Wolf for reminding me that PIPE: existed.  Otherwise,
  290. Fastjet would have been "a good idea, but how do I make it work?"
  291.  
  292. Fastjet was written with Lattice C 5.04.  The compaction mode 2
  293. subroutine is in assembly language.  After I win the lottery and retire
  294. to my country estate, I might rewrite the whole thing in assembler. 
  295. Watch for it!
  296.