Code:
//Here we start
# include<graphics.h>
# include<stdio.h>
# include<io.h>
# define ESC 27
# define LPT1 0
# define LPT2 1
# define write_to_prn(x) biosprint(0,x,LPT1)
int main()
{
int gd=0,gm=0;
initgraph(&gd,&gm,"..\\bgi");
circle(120,100,80);
printimage(0,0,getmaxx(),getmaxy());
return(0);
}
printimage(int x1,int y1,int x2,int y2)
{
int x,y,width;
width=x2-x1;
write_to_prn(ESC);
write_to_prn('1');
for(y=y1;y<y2;y+=4)
{
set_bit_image_mode(width);
for(x=x1;x<x2;x++)
write_to_prn(getpins(x,y));
write_to_prn("\n");
}
return;
}
set_bit_image_mode(int num)
{
int n1,n2;
n1=num%256;
n2=num/256;
write_to_prn(ESC);
write_to_prn('*');
write_to_prn('4');
write_to_prn(n1);
write_to_prn(n2);
return;
}
getpins(int x,int y)
{
// The 24 pins i want but it return negative values
unsigned char pins;
pins=(getpixel(x,y++)==0)?0:0;
pins|=(getpixel(x,y++)==0)?0:0;
pins|=(getpixel(x,y++)==0)?0:0;
pins|=(getpixel(x,y++)==0)?0:0;
pins|=(getpixel(x,y++)==0)?0:0;
pins|=(getpixel(x,y++)==0)?0:0;
pins|=(getpixel(x,y++)==0)?0:0;
pins|=(getpixel(x,y++)==0)?0:0;
pins=(getpixel(x,y++)==0)?0:0;
pins|=(getpixel(x,y++)==0)?0:-32768;
pins|=(getpixel(x,y++)==0)?0:16384;
pins|=(getpixel(x,y++)==0)?0:8192;
pins|=(getpixel(x,y++)==0)?0:2048;
pins|=(getpixel(x,y++)==0)?0:1024;
pins|=(getpixel(x,y++)==0)?0:512;
pins|=(getpixel(x,y++)==0)?0:256;
pins=(getpixel(x,y++)==0)?0:128;
pins|=(getpixel(x,y++)==0)?0:64;
pins|=(getpixel(x,y++)==0)?0:32;
pins|=(getpixel(x,y++)==0)?0:16;
pins|=(getpixel(x,y++)==0)?0:8;
pins|=(getpixel(x,y++)==0)?0:4;
pins|=(getpixel(x,y++)==0)?0:2;
pins|=(getpixel(x,y)==0)?0:1;
return pins;
}