                       GRAPHICS.COM and GRAPHICS PROFILES
    
    GRAPHICS.COM
    
    The graphics.com program enables the printing of either text or graphics
    video screens to an attached printer. graphics.com works with the
    following video hardware:
    
    Color Graphics Adapter     (CGA)
    Enhanced Graphics Adapter  (EGA)
    IBM PC Convertible LCD     (LCD)
    Video Graphics Array       (VGA)
    8514/A Adapter
    
    To run graphics.com, the graphics command must be issued from either the
    MS-DOS prompt or from a batch file. The syntax for the graphics command
    is as follows:
    
    graphics type [profile] [/b] [/r] [/lcd] [/printbox:id]
    
    where:
    
    type is the type of printer attached, as defined by the profile file.
    The types provided in the default profile file, graphics.pro, are:
    
         COLOR1                   Prints on an IBM Personal Computer
                                  Color Printer with black ribbon.
         COLOR4                   Prints on an IBM Personal Computer
                                  Color Printer with RGB (red,green,blue)
                                  ribbon.
         COLOR8                   Prints on an IBM Personal Computer
                                  Color Printer with CMY (cyan,magenta,
                                  yellow, and black) ribbon.
         GRAPHICS                 Prints on an IBM Personal Graphics
                                  Printer, IBM Proprinter, or IBM
                                  Quietwriter Printer.
         GRAPHICSWIDE             Prints on an IBM Personal Graphics Printer
                                  with an 11-inch wide carriage.
         THERMAL                  Prints; on an IBM PC-convertible Thermal
                                  Printer.
    
    profile is the name of the file that contains information on all
    supported printers. If this is omitted, the graphics.pro file is used.
    See GRAPHIC PROFILES for a description of profile files.

    Valid switches for the GRAPHICS command are defined as:
    
    /b
                                    Prints the background in color for valid
                                    printer types.
    /r
                                    Prints black and white (as seen on the
                                    screen) on the printer. The default is
                                    to print black as white and white as
                                    black.
    /lcd
                                    Prints image using the LCD aspect ratio
                                    of the IBM PC-CONVERTIBLE instead of the
                                    CGA aspect ratio. This is the same as
                                    the /printbox:lcd switch.
    /printbox:id
                                    Selects the printbox size. id should
                                    match the first operand of a printbox
                                    statement in the printer profile. The
                                    two options available with graphics.pro
                                    are std and  lcd. pb is the abbreviated
                                    form of printbox.
    
    
    NOTES
    
    If neither the /printbox nor the /lcd parameter is specified, the last
    printbox statement for a display is used.
    
    The screen can be printed in up to 19 shades of grey, or in up to eight
    different colors, depending on the printer.
    
    
    EXAMPLE
    
    To print a video screen to the printer, type the following command:
    
    graphics
    
    Then, when the screen displays the information you want to print, press
    the SHIFT and PRINTSCREEN keys at the same time.

    GRAPHIC PROFILES
    
    Graphic profiles are text files which contain a list of supported
    printers and the commands for each video mode for each of the printers
    listed.
    
    To define each printer's characteristics, a control structure is used
    consisting of two control statements; PRINTER and DISPLAYMODE.
    
    Each printer is defined by a PRINTER control sequence, followed by a set
    of DISPLAYMODE control sequences. The syntax is as follows:
    
    PRINTER
        - Printer description statements
         - COLORSELECT
         - COLORPRINT
         - DARKADJUST
    
    DISPLAYMODE
        - Display mode feature selection statements
         - SETUP
         - RESTORE
         - GRAPHICS
         - PRINTBOX
    
    Comments may be entered into the profile entries by starting them with
    a comma.
    
    PRINTER
    
        The PRINTER statement initializes the description of one or more
        printers. The syntax is as follows:
    
        PRINTER <type1>[,...[,<typeN>]]
    
        where type gives the printer being defined a name.
    
        The maximum number of PRINTER statements within one profile is 255.
        Each PRINTER statement has a maximum length (including leading
        blanks) of 128 characters.
    
                         PRINTER DESCRIPTION STATEMENTS
    
    COLORSELECT
    
        The COLORSELECT statement is an escape sequence that is sent to the
        printer to select an individual color print band. The COLORSELECT
        statement also tells the printscreen program the order in which
        colors are to be printed. The COLORSELECT statement is required for
        all color printers, but should not be used with black and white
        printers. The syntax of the COLORSELECT statement is:
    
        COLORSELECT colorid, <byte1>[,...[,<byteN>]]

        where
    
        colorid is a single byte alphanumeric code that uniquely identifies
        the color print band for the particular printer type. One
        COLORSELECT statement should be included for each color selectable
        on the printer. The maximum number of COLORSELECT statements for a
        given printer is 8.
    
        each byte value is a number ranging from 0 to 255. The string of
        bytes is the escape sequence for the printer to select the color.
    
        The maximum length (including leading blanks) of each COLORSELECT
        statement is 128 characters.
    
        If multiple COLORSELECT statements are included, they must be on
        consecutive lines and must appear before the COLORPRINT statements.
    
    
    COLORPRINT
    
        The COLORPRINT statement defines the RGB (red,green,blue) values for
        each of the possible print colors for the printer. The overlap of
        the printer color bands to obtain the print colors is also
        determined from these statements. The COLORPRINT statement is
        required for color printers, but should not be used with black and
        white printers. The syntax for the COLORPRINT statement is:
    
        COLORPRINT <red>,<green>,<blue>,<colorid1>[,...[,<coloridN>]]
    
        where
    
        red, green, and blue define values in the range of 0 to 63. When a
        screen pixel is read, its value (RGB) is obtained from a color
        translation table. The screen printing program compares this the
        value against the list of COLORPRINT statements and chooses the
        "best fit" in the list.
    
        colorid is a one-byte alphanumeric code, corresponding to the codes
        defined in the COLORSELECT statements.
    
        A COLORPRINT statement should be included for each color that can be
        printed, with a minimum of one statement per COLORSELECT statement.
        A maximum of 255 COLORPRINT statements is allowed. If more than one
        COLORPRINT statement is included in the printer definition, the
        COLORPRINT statements must be contiguous.
    
        There should be one COLORPRINT statement for the color WHITE, but
        the statement should only have red, green, and blue values, no
        colorid.

    DARKADJUST
    
        The DARKADJUST statement is used to modify the darkness of the
        individual black and white printer. This statement is not valid for
        color printers. The syntax of DARKADJUST is:
    
        DARKADJUST <darkvalue>
    
        where darkvalue is an adjustment value in the range of -63 to 63.
        The larger the number the lighter the printing. darkvalue has a
        default value of 0.
    
        Only one DARKADJUST statement is recognized, and it must come before
        the DISPLAYMODE statement in the printer definition structure. If
        more than one DARKADJUST statement is present, the last one will be
        used.
    
    
    DISPLAYMODE
        
        The DISPLAYMODE statement tells GRAPHICS which video modes are
        graphics modes. Only graphics display modes should be listed, as all
        video modes not listed are presumed to be text modes. Multiple
        DISPLAYMODE statements may be used within individual printer
        structures. The syntax of the DISPLAYMODE statement is:
         
        DISPLAYMODE <mode1> [,...[,<modeN>]]
    
        where mode represents the video modes that the following feature
        selection statements following the DISPLAYMODE statement. The
        maximum number of DISPLAYMODE statements is 255, with each statement
        limited to a length (including leading blanks) of 128 bytes.
    
                          FEATURE SELECTION STATEMENTS
    
    SETUP
    
        SETUP is an optional escape sequence that is sent to the printer to
        initialize the printer before each print screen operation. The
        syntax of the SETUP statement is:
    
        SETUP <byte1>[,...[,<byteN>]]
        
        where each byte is sent to the printer in sequence to put the
        printer in the proper mode (graphics, lines per inch, characters per
        inch, etc.).
        
        Each SETUP statement is limited to 128 characters, with a maximum of
        255 SETUP statements per profile. If a printer requires a SETUP
        string of more than 128 characters, multiple SETUP statements may be
        used. In this case, the SETUP statements must be contiguous.
    
    RESTORE
    
        RESTORE is an optional escape sequence that is sent to the printer
        to reset the printer after every print screen operation. provides.
        The syntax of the RESTORE statement is:
    
        RESTORE <byte1> [,...[,<byteN>]]
    
        where each byte is sent to the printer in sequence to put the
        printer in the normal print mode.
    
        Each RESTORE statement is limited to 128 characters, with a maximum
        of 255 RESTORE statements per profile. If a printer requires a
        RESTORE string of more than 128 characters, multiple RESTORE
        statements may be used. In this case, the RESTORE statements must be
        contiguous.
    
    GRAPHICS
    
        The GRAPHICS statement is a required statement which initializes the
        printer to print a line of graphics. The escape sequence specified
        is sent to the printer prior to every line printed. The escape
        character should be included in the line along with the data count
        (position indicated by HIGHCOUNT and LOWCOUNT keywords). The syntax
        for the GRAPHICS statement is:
    
        GRAPHICS <byte1> [,...[,<byteN>]]
    
        The keywords HIGHCOUNT and LOWCOUNT indicate the position of the
        bytes that are sent to the computer representing the low and high
        byte counts of the amount of data being sent to the printer for one
        line.
    
        The GRAPHICS statement is limited to 128 bytes in length.
    
    PRINTBOX
    
        The PRINTBOX statement specifies the number of horizontal and
        vertical printer dots that are needed to represent a single screen
        dot (pixel). A minimum of one PRINTBOX statement is required for
        every display mode. The syntax of the PRINTBOX statement is:
    
        PRINTBOX <id>,<hsize>,<vsize>[,ROTATE]
    
        where
    
        id is the size that matches the /PRINTBOX or /LCD switch in the
        graphics.com command.

        hsize and vsize represent the number of horizontal and vertical dots
        required to form one screen pixel on the screen. The valid
        combinations are as follows:
    
                                hsize     vsize
                                  2         1
                                  3         1
                                  2         2
                                  4         1
                                  4         2
                                  4         3
    
        ROTATE specifies printing the screen sideways on the printer.
    
        If no /PRINTBOX or /LCD switch is given in the graphics.com command,
        the last PRINTBOX statement for the given video graphics display
        mode is used. There must be a PRINTBOX statement with an id of STD.
    
    
    
                                    EXAMPLES
    
    The following two examples show how to read and write profile file
    entries. The first example comes from the graphics.pro file. This is the
    file shipped with MS-DOS 4.00 and has support for IBM printers. The
    example will demonstrate how to read a profile entry involving an eight
    color printer. The second example shows how to create an entry for an
    EPSON FX-286 black and white printer.
    
    EXAMPLE #1 : IBM 5182 CMY Ribbon
    
    The following is the text found in the graphics.pro file included with
    MS-DOS 4.00 for the IBM 5182 printer.
    
    
    PRINTER COLOR8           ;; 5182 CMY Ribbon
    
       ; Maximum Print width: 8"
       ; Horizontal BPI: 168 in 1:1 aspect ratio, 140 in 5:6 aspect ratio
       ; Vertical BPI: 84
       ; SETUP Statements contain the following escape sequences:
       ;   27,51,14 = set line spacing to 14/144
       ;   27,110,[0|1] = 0 sets aspect ratio to 5:6, 1 sets it to 1:1
       ; GRAPHICS Statements use ESC "L" with the last two bytes being
       ;  the data count (low,high)
    
      COLORSELECT Y,27,121        ;; yellow band
      COLORSELECT M,27,109        ;; magenta band
      COLORSELECT C,27,99         ;; cyan band
      COLORSELECT B,27,98         ;; black band
                                  ;;
                                  ;; Following RGB's represent the first 16
                                  ;; screen colors.
                                  ;; SCREEN COLOR        PRINT COLOR
                                  ;; ------------        -----------
      COLORPRINT 0,0,0,B          ;; BLACK          BLACK
      COLORPRINT 0,0,42,C         ;; BLUE           CYAN
      COLORPRINT 0,42,0,Y,C       ;; GREEN          GREEN
      COLORPRINT 0,42,42,C        ;; CYAN           CYAN
      COLORPRINT 42,0,0,Y,M       ;; RED            RED
      COLORPRINT 42,0,42,C,M      ;; PURPLE         PURPLE
      COLORPRINT 42,21,0,Y,C,M    ;; BROWN          BROWN
      COLORPRINT 42,42,42         ;; LOW WHITE      WHITE (NOTHING)
      COLORPRINT 21,21,21,B       ;; GREY           BLACK
      COLORPRINT 21,21,63,C       ;; HIGH BLUE      CYAN
      COLORPRINT 21,63,21,Y,C     ;; HIGH GREEN     GREEN
      COLORPRINT 21,63,63,C       ;; HIGH CYAN      CYAN
      COLORPRINT 63,21,21,Y,M     ;; HIGH RED       RED
      COLORPRINT 63,21,63,M       ;; MAGENTA        MAGENTA
      COLORPRINT 63,63,21,Y       ;; YELLOW         YELLOW
      COLORPRINT 63,63,63         ;; HIGH WHITE     WHITE (NOTHING)
    
      COLORPRINT 42,42,0,Y        ;; This statement maps the "yellow" in CGA
                                  ;;  palette 0 to yellow
                        ;;
      DISPLAYMODE 4,5,13,19       ;; 320x200
        SETUP 27,51,14,27,110,0   ;; aspect ratio = 5:6
        GRAPHICS 32,32,32,32,27,76,LOWCOUNT,HIGHCOUNT
        PRINTBOX STD,4,2,ROTATE
      DISPLAYMODE 6,14        ;; 640x200
         SETUP 27,51,14,27,110,0  ;; aspect ratio = 5:6
         GRAPHICS 32,32,32,32,27,76,LOWCOUNT,HIGHCOUNT
         PRINTBOX STD,4,1,ROTATE
      DISPLAYMODE 15,16       ;; 640x350
         SETUP 27,51,14,27,110,1  ;; aspect ratio = 1:1
         GRAPHICS 32,32,32,32,27,76,LOWCOUNT,HIGHCOUNT
         PRINTBOX STD,3,1,ROTATE
      DISPLAYMODE 17,18       ;; 640x480
         SETUP 27,51,14,27,110,1  ;; aspect ratio = 1:1
         GRAPHICS 32,32,32,32,27,76,LOWCOUNT,HIGHCOUNT
         PRINTBOX STD,2,1
    
    
    The different sections are described below:
    
    PRINTER
    
        The PRINTER COLOR8 statement defines this profile for the IBM 5182
        color printer using a CMY ribbon. This is the name that type refers
        to in the GRAPHICS.COM command line statement.

                         PRINTER DESCRIPTION STATEMENTS
                                        
    COLORSELECT
    
        The profile contains 4 COLORSELECT statements, corresponding to the
        4 available color bands that the printer is capable of printing. The
        escape codes following the COLORSELECT statements tell graphics.com
        how to select the individual colors. For example,
    
        COLORSELECT Y,27,121
    
        tells graphics.com that whenever it needs to use the color band that
        is represented by the letter Y (Yellow in this case), it must send
        an escape character (27) followed by a 121.
    
    
    COLORPRINT
    
        The profile contains 17 COLORPRINT statements. The first 16
        represent 16 common colors. More could be added. The final
        COLORPRINT statement is used to map the CGA palette 0 Yellow to the
        printer's yellow. This printer is a good example of how to re-map
        the screens RGB color model to another model. The IBM 5182 color
        printer uses a Cyan/Magenta/Yellow (CMY) color model. For example,
        to print the color green on an RGB color printer, you would probably
        see a statement like,
    
        COLORPRINT 0,42,0,G
    
        where 0,42,0 corresponds to the screen color green, and the G is
        (most likely) the letter chosen to represent the green color band of
        the printer. With the CMY color model, however, the statement is
    
        COLORPRINT 0,42,0,Y,C
    
        which instructs graphics.com to first print yellow, then cyan
        whenever it needs to print green.
    
    DARKADJUST
    
        Since this is a color printer, no value for DARKADJUST is needed.
    
    DISPLAYMODE
    
        For this example, one of the DISPLAYMODE statements, along with the
        Feature Selection statements that follow the DISPLAYMODE statement,
        will be discussed.
    
        DISPLAYMODE 4,5,13,19
    
        These display modes (4,5,13,19) are grouped together as they all
        have the same screen resolution 320x200. For the most part, the
        groupings represented above will be the ones used for color
        printers, as they are broken down by resolution.

                          FEATURE SELECTION STATEMENTS
    SETUP
    
        The SETUP escape sequence,
    
        SETUP 27,51,14,27,110,0
    
        first puts the printer into 14/144 line spacing by sending an escape
        (27) followed by the line spacing command (51), followed by the line
        spacing value (14). Next the aspect ratio is set to 5:6 by sending
        an escape (27) followed by the aspect ratio command (110), and
        finally the aspect ratio value (0).
    
    RESTORE
        
        The only change to the printer by the SETUP command was the line
        spacing. Since there is no way to obtain the line spacing value from
        the printer, there is no way to know what to set it back to.
        Therefore, no RESTORE statement is necessary.
        
    GRAPHICS
    
        The GRAPHICS statement contains the sequence of bytes sent to the
        printer before every line of data is sent. The statement,
    
        GRAPHICS 32,32,32,32,27,76,LOWCOUNT,HIGHCOUNT
    
        first prints 4 spaces (32) to give a border, followed by the escape
        sequence to set the printer up for graphics printing. The escape
        character (27) is followed by the graphics command (76). The
        LOWCOUNT and HIGHCOUNT keywords represent the order of the bytes
        representing the count of the data bytes following the escape
        sequence. The printer expects the count to be in the form of
        LOWCOUNT,HIGHCOUNT. Depending on the printer type these values may
        need to be re-ordered, or even placed in a different location in the
        command sequence.
    
    PRINTBOX
    
        The PRINTBOX statement,
    
        PRINTBOX STD,4,2,ROTATE
    
        describes the orientation and box sizes to use when printing from a
        standard (non-LCD) screen. The STD matches up to the /printbox:id
        switches used in the command line.
    
        The 4,2 represents the number of dots to print on the printer
        horizontally and vertically for each pixel on the screen. These dots
        are absolutes. This means that even if the image is rotated (using
        ROTATE), the order is not changed. In this case, the image is
        rotated, so each pixel on the screen will actually be turned into 2
        horizontal dots and 4 vertical dots on the printed image.

    EXAMPLE #2: EPSON FX-80 Printer
    
    The EPSON FX-80 printer is a black and white printer that has an 8"
    carriage. In double density mode there are 120 dots per inch
    horizontally and 72 dots per inch vertically. To make the printer work
    by printing 8 pins (that is what graphics.com expects), the line
    spacing needs to be set accordingly. The printer can print 72 dots per
    inch, but only 8 dots at a time, so we need to print those 8 dots 9
    times per inch. Since the printer accepts line spacing in parts of
    216ths of an inch, and we need to set the line spacing to 1/9 of an
    inch, the vertical line spacing should be 24/216.
    
    To set the FX-80 into 24/216 line spacing, graphics.com must send an
    escape sequence of esc (27) followed by the line spacing command (51)
    and the value of line spacing (24).
    
    To start the profile for the EPSON FX-80 printer, the name of the
    printer must be declared. To do this, the PRINTER statement is used as
    follows:
    
        PRINTER EPSONFX-80
    
    There are no color options available on the EPSON, and since each
    printer is different, the DARKADJUST option is left alone and will
    default to 0.
    
    Next, the different display modes need to be figured out. For the
    example, only one display mode group will be shown. The display mode
    will be the CGA-resolution compatible modes (320x200).
    
    The display modes that have the resolution of 320x200 are 4, 5, 13,
    and 19. The DISPLAYMODE statement for this is as follows:
        
        DISPLAYMODE 4,5,13,19
    
    Next, the printer must have a SETUP line to set the line spacing
    before every print screen operation. The syntax for this line is:
        
        SETUP  27,51,24      ; Set line spacing to 24/216"
    
    Since the printer resets itself back into text mode after every line
    of graphics has been printed, there is no need for a RESTORE command.
    
    After that, the commands to tell the printer to print a line of
    graphics must be set up. The command sequence to put the printer into
    graphics mode is esc (27) followed by the graphics command (76)
    followed by two bytes of count data in the low-count, high-count
    order. To give the image a border, spaces can be printed before
    sending the printer into graphics mode. The syntax for this statement
    is:
        
        GRAPHICS 32,32,32,32,32,27,76,LOWCOUNT,HIGHCOUNT
    The final step in the process is to decide how to print the image. The
    orientation of the screen is best represented if the image is rotated.
    Therefore, we must map the vertical dots on the screen (200) to
    horizontal dots on the printer (120 dpi) and horizontal dots on the
    screen (320) to vertical dots on the printer (72 dpi).
    
    Since the area that will be printed is a result of the size of the
    boxes chosen, the size of the box needs to be big enough to give a
    good-sized picture, yet small enough to fit on the page. Using a
    horizontal box size of 1 printer dot per screen dot would result in
    200 dots being printed, and would be 1.67" across on the printer.
    Using this fact, 4 boxes should be printed per screen dot, resulting
    in a 6.7" wide picture (since it is rotated, this represents height
    for the image). To figure out the vertical box size, the horizontal
    size must be taken into consideration. Since the image on the printer
    is 6.7" across, the vertical image needs to be bigger to keep the
    perspective the same as the screen.
    
    The screen is 320 dots wide, and the printer prints at 72 dots per
    inch vertically. If the box size chosen were to be 1, 320 dots would
    be printed resulting in an image that is 4.4" long. This is out of
    proportion for what we need, but an image that is 8.8" long would be
    just about the right size. 13.2" would not only be out of proportion,
    but would be off the standard 8-1/2 x 11 sheet of paper. Therefore,
    the horizontal and vertical box sizes for the PRINTBOX statement
    should be 4 and 2 respectfully. The printbox size is set to STD. The
    syntax for the PRINTBOX statement should be:
    
        PRINTBOX   STD,4,2,ROTATE
    
    The final profile for the EPSON FX-80 is included on the next page.
    
    
    PRINTER EPSONFX-80
    
      DISPLAYMODE 4,5,13,19
        SETup 27,51,24
        GRAPHICS 32,32,32,32,32,32,27,76,LOWCOUNT,HIGHCOUNT
        PRINTBOX STD,4,2,ROTATE
    
      DISPLAYMODE 6,14
        SETup 27,51,24
        GRAPHICS 32,32,32,32,32,32,27,76,LOWCOUNT,HIGHCOUNT
        PRINTBOX STD,4,1,ROTATE
    
      DISPLAYMODE 15,16
        SETup 27,51,24
        GRAPHICS 32,32,32,32,32,32,32,27,76,LOWCOUNT,HIGHCOUNT
        PRINTBOX STD,2,1,ROTATE
    
      DISPLAYMODE 17,18
        SETup 27,51,24
        GRAPHICS 27,76,LOWCOUNT,HIGHCOUNT
        PRINTBOX STD,2,1,ROTATE
