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

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







PRODUCT : TURBO C NUMBER : 453
VERSION : 2.0
OS : PC-DOS
DATE : MARCH 10, 1989 PAGE : 1/3

TITLE : PRINTING GRAPHICS




The following code is an example function which prints a graphics
screen on an Epson compatible printer.


PROTOTYPE: printimage(int left, int top, int right, int bottom);

-----------------------------------------------------------------

#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.
Nbytes is the number of bytes to print. */

static void bitImage(int Nbytes)
{

register int n1, n2;

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

prn_putc(ESC);
prn_putc('*');
prn_putc(4);
prn_putc(n1);
prn_putc(n2);

}

/* Get pixels from the screen and convert them to
the printer's pin order. */














PRODUCT : TURBO C NUMBER : 453
VERSION : 2.0
OS : PC-DOS
DATE : MARCH 10, 1989 PAGE : 2/3

TITLE : PRINTING GRAPHICS




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;
}

/* Graphics print function. */

int printimage(int left, int top, int right, int bottom)
{
int x, y, width, height;

width = right-left;
height = bottom-top;

/* Initialize line spacing to 7/72" */
prn_putc(ESC);
prn_putc('1');

for (y=0; y {
bitImage(width);

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

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

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














PRODUCT : TURBO C NUMBER : 453
VERSION : 2.0
OS : PC-DOS
DATE : MARCH 10, 1989 PAGE : 3/3

TITLE : PRINTING GRAPHICS




An example program which demonstrates a call to the above
function.

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

main(){

int driver, mode,x,y;
driver = DETECT; /* autodetect */
mode = 0;
initgraph(&driver, &mode, "");
x=getmaxx();
y=getmaxy();

/* draw some things */
rectangle(0,0,x,y);
circle(300,200,100);
circle(210,110,50);
circle(390,110,50);
circle(270,170,10);
circle(272,173,3);
circle(330,170,10);
circle(332,173,3);
circle(300,200,10);
moveto(280,220);
lineto(290,230);
lineto(310,230);
lineto(320,220);

/* Call the graphics print function. */
printimage(0,0,x,y); /* Print the entire screen. */

closegraph();
return 0;
}
















  3 Responses to “Category : C Source Code
Archive   : BCPPTECH.ZIP
Filename : TI453.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/