Category : C Source Code
Archive   : BCPPTECH.ZIP
Filename : TI720.ASC

 
Output of file : TI720.ASC contained in archive : BCPPTECH.ZIP







PRODUCT : Borland C++ NUMBER : 720
VERSION : 2.0
OS : DOS
DATE : February 25, 1992 PAGE : 1/3

TITLE : Printing a Graphics Screen to an Epson Printer




/************************************************************

Name PrintImage

Description Prints an image to an Epson compatible printer,
ala GetImage and PutImage.

Syntax printimage(int x1, int y1, int x2, int y2);

************************************************************/

#include
#include
#include

#define ESC '\x1B'
#define LPT1 0
#define LPT2 1
#define prn_putc(x) biosprint(0,(x),LPT1)

/*
Sets Epson printer to bit image mode.
N is the number of bytes to print.
*/
static void bitImage(int N)
{
register int n1, n2;

n2 = N >> 8;
n1 = N - (n2 << 8);

prn_putc(ESC);
prn_putc('*');
prn_putc(4); /* K=standard density,
L=double density,
Y=dbl speed + dbl density,
Z=quad density */
prn_putc(n1);
prn_putc(n2);
}

/*
Get pixels from the screen and convert them to













PRODUCT : Borland C++ NUMBER : 720
VERSION : 2.0
OS : DOS
DATE : February 25, 1992 PAGE : 2/3

TITLE : Printing a Graphics Screen to an Epson Printer




the printer's pin order.
*/
static unsigned char getScrBits(int x, int y)
{
unsigned char firePins;

firePins = (getpixel(x, y++)==0)? 0: 0x80;
firePins |= (getpixel(x, y++)==0)? 0: 0x40;
firePins |= (getpixel(x, y++)==0)? 0: 0x20;
firePins |= (getpixel(x, y++)==0)? 0: 0x10;
firePins |= (getpixel(x, y++)==0)? 0: 0x08;
firePins |= (getpixel(x, y++)==0)? 0: 0x04;
firePins |= (getpixel(x, y++)==0)? 0: 0x02;
firePins |= (getpixel(x, y )==0)? 0: 0x01;

return firePins;
}

/*
Prints the image
*/

int printimage(int x1, int y1, int x2, int y2)
{
int x, y, width, height;

width = x2-x1;
height = y2-y1;

for (y=0; y {
/* Initialize line spacing to 7/72" */
prn_putc(ESC); prn_putc('1');

bitImage(width);

for (x=0; x prn_putc(getScrBits(x,y));

prn_putc('\n');
}
return 0;
}













PRODUCT : Borland C++ NUMBER : 720
VERSION : 2.0
OS : DOS
DATE : February 25, 1992 PAGE : 3/3

TITLE : Printing a Graphics Screen to an Epson Printer




/*
Initialize graphics screen
*/

void InitGraf(int *hor, int *ver)
{
int gmode, i;
int gdriver = DETECT;
struct viewporttype vp;

initgraph(&gdriver, &gmode, "");
getviewsettings( &vp );
*hor = (vp.right - vp.left);
*ver = (vp.bottom - vp.top);
for (i=0; i<(*hor); i+=10) line(i,0,i,*ver);
for (i=0; i<(*ver); i+=10) line(0,i,*hor,i);
}

main()
{
int h, v;

InitGraf(&h,&v);

printimage(0,0,h,v);

closegraph();
return 0;
}






















  3 Responses to “Category : C Source Code
Archive   : BCPPTECH.ZIP
Filename : TI720.ASC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/