Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

turbo pascal 6 (DOS) print graphics window

9 views
Skip to first unread message

dimitrios katsoulis

unread,
Mar 8, 2000, 3:00:00 AM3/8/00
to
I have created a pascal application in DOS mode.

How can I print my graphics window to a printer from inside the
application?

I would appreciate any tips.

john antoniades


Shawn Rapp

unread,
Mar 8, 2000, 3:00:00 AM3/8/00
to
That one is not a easy one but a feasiable one. Especially since HP has
made documentation more easily accessable than in the past. Back when DOS
was cool you either had a bucket load of money to give for spec sheets to
printer companies or hacked them out bit by bit...litterly
What I would recommend is getting some docs on HP laser printer II format
which is universal excepted standard for just about all printers on how to
do graphics. (cept for Cannon BJ printers and a few others) But the
protocal is called GRASP i believe. (its been a while) and it uses a
standard set of vector commands to tell the printer how to draw your
picture. Quite similar to the way True Type fonts work.
Their is another HP standard that allows horizontal lines to be sent at a
time so the printer doesn't have to buffer your picture (takes along time to
get a full page pic) but I believe these become more proprietary. Again I
would recommend sticking to the B&W laser printer II of HP. If B&W isn't
good enough you will either have to start hacking printer protocals out or
figure some means of being able to have windows do the printing by making a
bitmap and than make a small Windows app that gets executed to print through
the windows drivers.

dimitrios katsoulis wrote in message
<38C63A83...@skiathos.physics.auth.gr>...

Woodrow_Stool

unread,
Mar 8, 2000, 3:00:00 AM3/8/00
to
That was maybe the most incoherent explanation of DOS graphics printing I
have ever heard.

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...

Dr John Stockton

unread,
Mar 8, 2000, 3:00:00 AM3/8/00
to
JRS: In article <38C63A83...@skiathos.physics.auth.gr> of Wed, 8
Mar 2000 13:33:23 in news:borland.public.turbopascal, dimitrios

katsoulis <dk...@skiathos.physics.auth.gr> wrote:
>I have created a pascal application in DOS mode.
>
>How can I print my graphics window to a printer from inside the
>application?

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.

Shawn Rapp

unread,
Mar 8, 2000, 3:00:00 AM3/8/00
to
Well geez... i just woke up when i wrote it. I don't do so good when the
time is B.C. (Before Coffee) =)
Thanks for explaining my cryptic pingeon scripted message.

Woodrow_Stool wrote in message <8a6ltp$7f...@bornews.borland.com>...

Michael Day (TeamB)

unread,
Mar 9, 2000, 3:00:00 AM3/9/00
to
unit lpunit;
interface
FUNCTION LJBEG(LPORT:BYTE; LSIZE:WORD):BOOLEAN;
PROCEDURE LJEND;
PROCEDURE LJPRINT(LAND:BOOLEAN);

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.

0 new messages