home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / grafik / gp / graphprn.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1990-04-30  |  2.4 KB  |  75 lines

  1. Unit GraphPRN;  { Use HardCopy(6) for screen circle to printer circle }
  2.  
  3. Interface
  4.  
  5. Uses Graph,         { Used to get the Image from the Screen }
  6.      Printer2;      { Used to circumvent DOS's striping of  }
  7.                     { $1A = ^Z from output stream ( a MUST  }
  8.                     { for Graphics output!                  }
  9.  
  10. Procedure HardCopy (Gmode: Integer);
  11. { Procedure HardCopy prints the current ViewPort        }
  12. {   to an IBM or Epson compatible printer.              }
  13. {                                                       }
  14. { Valid Gmode numbers are :                             }
  15. {     -4 to -1 for Epson and IBM Graphic Printers       }
  16. {      0 to 7 for Epson Printers                        }
  17.  
  18. Implementation
  19.  
  20. Procedure HardCopy(Gmode : Integer);
  21.  
  22. Const
  23.    Bits : Array [0..7] of Byte = (128,64,32,16,8,4,2,1);
  24.  
  25. Var
  26.    X,Y,YOfs           : Integer;
  27.    BitData,MaxBits    : Byte;
  28.    Vport              : ViewPortType;
  29.    Height,Width       : Word;
  30.    HIBit,LoBit        : Char;
  31.    LineSpacing,
  32.    GraphPrefix        : String[10];
  33.  
  34. Begin
  35.   LineSpacing := #27+'3'+#24;  { 24/216 inch line spacing     }
  36.   Case Gmode of
  37.        -1: GraphPrefix := #27+'K'; { Std. Density             }
  38.        -2: GraphPrefix := #27+'L'; { Double Density           }
  39.        -3: GraphPrefix := #27+'Y'; { Dbl. Density, Dbl. Speed }
  40.        -4: GraphPrefix := #27+'Z'; { Quad. Density            }
  41.      0..7: GraphPrefix := #27+'*'+Chr(Gmode); { 8-Pin Bit Img }
  42.     Else
  43.      Exit;
  44.   End;
  45.   GetViewSettings ( Vport );
  46.   Height := Vport.Y2-Vport.Y1;
  47.   Width := Vport.X2-Vport.X1+1;  { added +1 to # cols for printing to }
  48.   HiBit := Chr(Hi(Width));       { make room for right vertical boundary, }
  49.   LoBit := Chr(Lo(Width));       { otherwise rectangle(0,0,GetMaxX,GetMaxY }
  50.   Write( Lst, LineSpacing );     { max border will print with no right on box }
  51.   Y := 0;
  52.   While Y < Height Do
  53.   Begin
  54.      Write ( Lst,GraphPrefix,LoBit,HiBit );
  55.      For X := 0 to Width-1 Do
  56.      Begin
  57.         BitData := 0;
  58.         If Y + 7 <= Height
  59.           Then MaxBits := 7
  60.         Else
  61.           MaxBits :=Height - Y;
  62.         For YOfs := 0 to MaxBits Do
  63.         Begin
  64.           If GetPixel ( X, YOfs+Y ) > 0
  65.              Then BitData := BitData or Bits[YOfs];
  66.         End;
  67.         Write( Lst, Chr(BitData) );
  68.      End;
  69.      Writeln ( Lst );
  70.      Inc(Y,8);
  71.   End;
  72. End;
  73. End.
  74.  
  75.