Board index » delphi » Graphics printing on 9-pin printer

Graphics printing on 9-pin printer

To my suprise i can't find a the sulotion anyware, up to now.

Is there a way to print graphics on my 9-pin printer with Turbo Pascal
7.0  ???????

Is there a way ?

How ?

Is there a unit a something ??

With a working example would be very nice...

 

Re:Graphics printing on 9-pin printer


In article <34c0eb43.2594...@news.euro.net>,
   hih...@concepts.nlDELETE_THIS (CP Van Dommelen) wrote:

Quote

>To my suprise i can't find a the sulotion anyware, up to now.

>Is there a way to print graphics on my 9-pin printer with Turbo Pascal
>7.0  ???????

There will likely be some instructions in your printer manual.

Bruce Winterbon
bwint...@intranet.ca
http://intranet.ca:80/~bwinterb

All states have laws to protect the rich from the poor.
Few attempt the more difficult task of protecting the
poor from the rich.

Re:Graphics printing on 9-pin printer


Quote
bwint...@intranet.ca (Bruce Winterbon) wrote:
>>Is there a way to print graphics on my 9-pin printer with Turbo Pascal
>>7.0  ???????

>There will likely be some instructions in your printer manual.

Well, there is.
But i can't make it work...
Something like : ESC ^ m n1 n2....

Re:Graphics printing on 9-pin printer


Quote
CP Van Dommelen wrote in message <34c0eb43.2594...@news.euro.net>...

>To my suprise i can't find a the sulotion anyware, up to now.

>Is there a way to print graphics on my 9-pin printer with Turbo Pascal
>7.0  ???????

>Is there a way ?

>How ?

>Is there a unit a something ??

>With a working example would be very nice...

Hi!

 First that I wanna say is  that printing in MS-DOS is rather difficult. You
see that each printer has special set of codes to initialize graphics
printing mode. And as usuall this codes are not the same. So, if you wanna
write a program that will print on a varius printers (for example user
choose the printer from list) you will have to make
a database from wich you will take this special code for choosen by user
printer. As
usuall this database is very large and a programmers should find special
codes for each printner. It's very bore. But if your printer is Epson or
compaitable you can use the follow code:

unit printscr;
interface
uses graph,crt,printer;
{001}  PROCEDURE Copy_to_PRN_G(Xst,Yst,Xend,Yend:integer;

{ Size of picture  you want to print}
                             Bk1_color,Bk2_color:word;   { Background
lors   }
                             Inverce:boolean;            {  inverse?   }
                             Mode:byte);                 { This specail
ode  }
{002}  PROCEDURE Copy_to_PRN_V(Xst,Yst,Xend,Yend:integer;

{ Size of picture  you want to print}
                             Bk1_color,Bk2_color:word;   { Background
lors   }
                             Inverce:boolean;            { Inverse?}
                             Mode:byte);                 { code}

implementation

{001}  PROCEDURE Copy_to_PRN_G                (Xst,Yst,Xend,Yend:integer;
 Bk1_color,Bk2_color:word;
                             Inverce:boolean;
                             Mode:byte);
    var
         Scan_Line   : Integer;
         n1,n2       : Byte;
{..........................................................................}
{001/001} FUNCTION Construct_Byte(X,Y:integer):byte;
 const
        Bits         : Array[0..7] of Byte =(128,64,32,16,8,4,2,1);
 var
        P            : Word;
        CByte,Bit    : Byte;
        YY           : Integer;
 BEGIN
 CByte:=0;
 for Bit:=0 to 7 do
 begin
 YY:=Y+Bit;
 P:= GetPixel(X,YY);
  if (YY<=Yend)and(P<>Bk1_color)and(P<>Bk2_color)
  then inc(CByte,Bits[bit]);
 end;
 Construct_Byte:=CByte
 end;
{..........................................................................}
{001/002} PROCEDURE Do_Line;
 var
     XPixel          : Integer;
     PrintByte       : Byte;
Begin
{
if Mode=1 then Write(Lst,#27'L') else Write(Lst,#27'*',Chr(Mode));

Quote
}

if Mode=1 then Write(Lst,#27+#42+char(mode)) else
Write(Lst,#27'*',Chr(Mode));
Write(Lst,Chr(n1),Chr(n2));
for XPixel:=Xst to Xend do
 begin
 PrintByte:=Construct_Byte(Xpixel,Scan_Line);
 if Inverce then PrintByte:= not PrintByte;
 Write(Lst,Chr(PrintByte));
 end;
 Write(Lst,#10)
 end;
{..........................................................................}
const        Ok_Quit: Boolean=false;
begin
Mode:=Mode mod 7;
if Mode in [0,5] then mode:=4;
Write(Lst,#27+'3'+#24);
n1:=Lo(Succ(Xend-Xst));
n2:=Hi(Succ(Xend-Xst));
Scan_Line:=Yst;
While Scan_Line<Yend do
begin
if keypressed and (readkey=#27) then Ok_Quit:=true;
if not Ok_Quit then
begin
Do_Line;
inc(Scan_Line,8)
end;
end;
write(Lst,#27+#2);
Ok_Quit:=false;
end;

{002}  PROCEDURE Copy_to_PRN_V(Xst,Yst,Xend,Yend:integer;
Bk1_color,Bk2_color:word;
                            Inverce:boolean;
                             Mode:byte);
var
         Scan_Line   : Integer;
         n1,n2       : Byte;
{..........................................................................}
{002/001} FUNCTION Construct_Byte(X,Y:integer):byte;
 const
         Bits        : Array[0..7] of Byte =(128,64,32,16,8,4,2,1);
 var
        P            : Word;
        CByte,Bit    : Byte;
        XX           : Integer;
 BEGIN
 CByte:=0;
 for Bit:=0 to 7 do
 begin
 XX:=X+Bit;
 P:= GetPixel(XX,Y);
 if (XX<=Xend)and(P<>Bk1_color)and(P<>Bk2_color)
 then inc(CByte,Bits[bit]);
 end;
 Construct_Byte:=CByte
 end;
{..........................................................................}
{002/002} PROCEDURE Do_Line;
 var
     YPixel          : Integer;
     PrintByte       : Byte;
Begin
{
if Mode=1 then Write(Lst,#27'L') else Write(Lst,#27'*',Chr(Mode));

Quote
}

if Mode=1 then Write(Lst,#27+#42+char(mode)) else
Write(Lst,#27'*',Chr(Mode));
Write(Lst,Chr(n1),Chr(n2));
for YPixel:=Yend downto Yst do
 begin
 PrintByte:=Construct_Byte(Scan_Line,Ypixel);
 if Inverce then PrintByte:= not PrintByte;
 Write(Lst,Chr(PrintByte));
 end;
 Write(Lst,#10);
 end;
{..........................................................................}
const        Ok_Quit: Boolean=false;
begin
Mode:=Mode mod 7;
if Mode in [0,5] then mode:=4;
Write(Lst,#27+'3'+#24);
n1:=Lo(Succ(Yend-Yst));
n2:=Hi(Succ(Yend-Yst));
Scan_Line:=Xst;
While Scan_Line<Xend do
begin
if keypressed and (readkey=#27) then Ok_Quit:=true;
if not Ok_Quit then
begin
Do_Line;
inc(Scan_Line,8)
end;
end;
write(Lst,#27+#2);
Ok_Quit:=false;
end;

end.

{ Mode is a byte with wich you can set up width, quality of the printing }

It works well(at least at my 9 pin Citizen and my friend's Epson) but I
advise you to press 'Print  Screen' button  in Windows'95 then screen will
be copyed in the buffer. After that you can paste it in Microsoft Paint,
Word or anywhere else and print.

Note: If you don't have special codes for your printer see file
'graphics.pro' wich goes with MS-DOS 6.22 (may be in other versions of
MS-DOS to, I don't know).
This is a large library of special codes to some printers.

     Sunny.

P.S.: Thanx from you will be appreciated  :)

Other Threads