Tuesday, February 4, 2020

Character Generation program using C-Language

Character Generation program using C-Language

Following program will draw character using bitmap method.

#include<stdio.h>
#include<conio.h>
#include<graphics.h>

void main()
{
int gd=DETECT,gm,i,j;
initgraph(&gd,&gm,"c:\\turboc3\\bgi");
int a[8][5]={{0,0,1,0,0},
    {0,1,1,1,0},
    {0,1,0,1,0},
    {1,1,0,1,1},
    {1,0,0,0,1},
    {1,1,1,1,1},
    {1,0,0,0,1},
    {1,0,0,0,1}};

int b[8][5]={{1,1,1,1,0},
    {1,0,0,0,1},
    {1,0,0,0,1},
    {1,1,1,1,0},
    {1,0,0,0,1},
    {1,0,0,0,1},
    {1,0,0,0,1},
    {1,1,1,1,0}};

int c[8][5]={{0,1,1,1,0},
    {1,0,0,0,0},
    {1,0,0,0,0},
    {1,0,0,0,0},
    {1,0,0,0,0},
    {1,0,0,0,0},
    {1,0,0,0,0},
    {0,1,1,1,0}};
int d[8][5]={{1,1,1,1,0},
    {1,0,0,0,1},
    {1,0,0,0,1},
    {1,0,0,0,1},
    {1,0,0,0,1},
    {1,0,0,0,1},
    {1,0,0,0,1},
    {1,1,1,1,0}};
for(i=0;i<8;i++)
{
for(j=0;j<5;j++)
{
putpixel(100+j,100+i,5*a[i][j]);
putpixel(107+j,100+i,6*b[i][j]);
putpixel(114+j,100+i,7*c[i][j]);
putpixel(121+j,100+i,9*d[i][j]);
}
}
getch();

}