Why Graphics Screen Printing Is Usually In Landscape Mode (71794)



The information in this article applies to:

  • Microsoft QuickBASIC 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBASIC 4.5
  • Microsoft Basic Professional Development System for MS-DOS 7.0
  • Microsoft Basic Professional Development System for MS-DOS 7.1
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b

This article was previously published under Q71794

SUMMARY

Elsewhere in this Knowledge Base, Microsoft provides sample programs for printing a Basic graphics screen to an Epson printer. These sample programs all use the landscape mode of printing. Landscape mode means that the screen image is turned sideways on the printer output. Below is an explanation of why the sample programs use landscape mode instead of portrait mode.

MORE INFORMATION

For code examples of printing the various Basic graphics SCREEN modes to an Epson printer, search for the following words:

Epson and print and screen and QuickBasic

The landscape format is used in these sample programs for two main reasons:

  1. Basic graphics SCREEN modes are wider (more pixels across the screen) than they are tall (less pixels from the top to the bottom of the screen). A printer in landscape mode uses the paper in an orientation similar to the physical screen; the paper page is longer than it is wide.
  2. The physical printer pins on an Epson-style dot matrix printer are arranged vertically, as follows:

    Pin number:
    8
    7
    6
    5
    4
    3
    2
    1
    0

When you pass a byte of graphics data to the printer, each bit in that byte corresponds to one of the first eight printer pins (0-7). If the bit in the data byte is set, the printer pin fires.

Because video memory is laid out in horizontal scan lines, it has to be "turned sideways" so that the scan-line data can be sent directly to the printer; thus, the data from a horizontal scan line in video memory corresponds correctly to the vertical orientation of the printer pins.

How to Print with Portrait Mode Instead of Landscape Mode

To print video memory in portrait mode on a dot matrix printer, you have to examine video memory "sideways," taking into account the actual layout of video memory for the chosen screen mode, and taking the nth bit from each of a group of eight scan lines to form a data byte that could be sent to the printer. Bitwise operations in Basic can be performed with the AND and OR operators, for example
   IF <var> AND 2 ^ n THEN <var2> = <var2> OR 2 ^ n
				
will check the nth bit in <var> and set the corresponding bit in <var2> if that bit is set in <var>.

The layout of a given SCREEN mode in video memory can be found in several reference books, including:

  1. "Programmer's Guide to PC and PS/2 Video Systems" by Richard Wilton, published by Microsoft Press.
  2. "PC Programmer's Source Book" by Thom Hogan, published by Microsoft Press.

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:KB71794