How can I print my graphics window to a printer from inside the
application?
I would appreciate any tips.
john antoniades
dimitrios katsoulis wrote in message
<38C63A83...@skiathos.physics.auth.gr>...
Printing, DOS or Windows, is generally done by rasterizing a bitmap on the
host PC and then transmitting the bitmap to the printer with the appropriate
control bytes, known as "escape sequences". Exceptions to this rule are
primarily Postscript and HPGL, the latter is used to drive pen plotters.
Both are vector based page description languages
Here are the primary printer families, each with their own unique set of
escape sequences:
Epson 9 pin
Epson 24 pin
IBM 24 pin
HP LaserJet/DeskJet (known as "PCL")
Epson color inkjet (known as "ESC/2")
New Canon proprietary
HP PaintJet
HP ThinkJet
HPGL
Postscript
The old Canons used a Epson 24 pin color dot matrix emulation, the new ones
have their own set of escape sequences.
There are a number of companies that have developed DOS BGI drivers for
graphics mode printing. Here's one that I know is still in business:
http://www.ryledesign.com/bgiprt.html
In addition you can simply do a screen dump on most DOS systems - that is
invoked by calling the screen dump interrupt, which is 05. Just invoke it
(there are no register parameters required) and if DOS graphics.com is
loaded properly you'll get a screen dump.
Hope this helps.
Shawn Rapp <sr...@gci.net> wrote in message
news:8a5ssn$70...@bornews.borland.com...
In the limit of desperation, you can scan the whole screen with a
GetPixel loop. and send the results to a printer in whatever format it
needs. I've done it. With a postscript printer, maybe run-length
encode the raster lines, to save time.
For a printer-independent method, it ***might*** be possible to run in a
Windows DOS box, send an Alt-PrintScreen to Windows, and then instruct
Windows to paste into a drawing application & print it.
Otherwise, it might be better to send "copies" of the screen-drawing
commands to a printer/plotter/file.
--
© John Stockton, Surrey, UK. j...@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
<URL: http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
<URL: ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ;
<URL: http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ.
Woodrow_Stool wrote in message <8a6ltp$7f...@bornews.borland.com>...
implementation
USES GRAPH,CRTI;
TYPE STRING12 = STRING[12];
VAR LST : TEXT;
CONST PRNPORT : WORD = 0; {0=LPT1, 1=LPT2}
{-------------------------------------------------------------}
{LASER PRINTER SETUP TABLES}
const ESCHR = #$1B;
NULL = #0;
PRNBEG = ESCHR+'E'; {RESET PRNTR, EJECT PAGE IF REQ}
PRN75 = ESCHR+'*t75R'; {SET 75 DOTS PER INCH}
PRN100 = ESCHR+'*t100R'; {SET 100 DOTS PER INCH}
PRN150 = ESCHR+'*t150R'; {SET 150 DOTS PER INCH}
PRN300 = ESCHR+'*t300R'; {SET 300 DOTS PER INCH}
PRITOP = ESCHR+'&a100H'+ {SET CURSOR TO START POS}
ESCHR+'&a100V';
PRLINI = ESCHR+'*b'; {RASTER LINE HEADER FOR PRINTER}
PRLINE = 'W'; {RASTER LINE HEADER FOR PRINTER}
PRNRST = ESCHR+'*r1A'; {BEGIN RASTER GRAPHICS}
PRNEND = ESCHR+'*rB'; {END RASTER GRAPHICS}
PRNRES = ESCHR+'E'; {RESET PRINTER AND EJECT PAGE}
FUNCTION PRNSTAT:BYTE; ASSEMBLER;
ASM
MOV AH,2
MOV DX,[PRNPORT]
INT $17
MOV AL,AH
END;
PROCEDURE PRINTCHAR(C:CHAR); ASSEMBLER;
ASM
MOV AL,[C]
MOV DX,[PRNPORT]
MOV AH,0
INT $17
END;
PROCEDURE PRINT(C:CHAR);
BEGIN
WHILE PRNSTAT AND $a0 <> $80 DO {NOP};
PRINTCHAR(C);
END;
PROCEDURE LPRINT(S:STRING);
VAR I : WORD;
BEGIN
FOR I := 1 TO LENGTH(S) DO
BEGIN
PRINT(S[I]);
END;
END;
FUNCTION FSTR(L:LONGINT):STRING12;
VAR S:STRING;
BEGIN
STR(L,S);
FSTR := S;
END;
{---------------------------------------------}
{PREPARE EXTERNAL PRINTER FOR OUTPUT}
FUNCTION LJBEG(LPORT:BYTE; LSIZE:WORD):BOOLEAN;
BEGIN
LJBEG := TRUE;
IF LPORT > 2 THEN EXIT;
PRNPORT := LPORT;
LPRINT(PRNBEG);
CASE LSIZE OF
75: LPRINT(PRN75);
100: LPRINT(PRN100);
150: LPRINT(PRN150);
300: LPRINT(PRN300);
ELSE LJBEG := FALSE;
END;
END;
{---------------------------------------------}
{RESTORE EXTERNAL PRINTER TO NORMAL OPERATION}
PROCEDURE LJEND;
BEGIN
LPRINT(PRNRES);
END;
{----------------------------------------------}
{PRINT GRAPHICS AS LANDSCAPE}
PROCEDURE DOLAND;
VAR Y,X,L,I,B : WORD;
C : BYTE;
D : CHAR;
RASTER : STRING;
BEGIN
FOR X := GETMAXX DOWNTO 0 DO
BEGIN
Y := 0;
L := (GETMAXY+1) DIV 8;
LPRINT(PRLINI+FSTR(L)+PRLINE);
FOR B := 1 TO L DO
BEGIN
D := #0;
FOR I := 0 TO 7 DO
BEGIN
C := GETPIXEL(X,Y);
IF C > 0 THEN C := 1;
D := CHAR((ORD(D) SHL 1) OR C);
INC(Y);
END;
RASTER[B] := D;
END;
RASTER[0] := CHAR(B);
LPRINT(RASTER);
END;
END;
{----------------------------------------------}
{PRINT GRAPHICS AS PORTRAIT}
PROCEDURE DOPORT;
VAR Y,X,L,I,B : WORD;
C : BYTE;
D : CHAR;
RASTER : STRING;
BEGIN
FOR Y := 0 TO GETMAXY DO
BEGIN
X := 0;
L := (GETMAXX+1) DIV 8;
LPRINT(PRLINI+FSTR(L)+PRLINE);
FOR B := 1 TO L DO
BEGIN
D := #0;
FOR I := 0 TO 7 DO
BEGIN
C := GETPIXEL(X,Y);
IF C > 0 THEN C := 1;
D := CHAR((ORD(D) SHL 1) OR C);
INC(X);
END;
RASTER[B] := D;
END;
RASTER[0] := CHAR(B);
LPRINT(RASTER);
END;
END;
{----------------------------------------------}
{DUMP THE SCREEN TO EXTERNAL LASER PRINTER}
{LAND=TRUE DO LANDSCAPE; LAND=FALSE DO PORTRAIT}
PROCEDURE LJPRINT(LAND:BOOLEAN);
BEGIN
LPRINT(PRITOP); {POSITION CURSOR}
LPRINT(PRNRST); {ENTER GRAPHICS MODE}
IF LAND THEN
DOLAND
ELSE
DOPORT;
LPRINT(PRNEND); {CLOSE PRINTER GRAPHICS}
END;
end.