Tuesday, January 21, 2014

Character Generation using BitMap

Program for character generation using bitMap

#include<conio.h>
#include<stdio.h>
#include<graphics.h>
void main()
{
int gd= DETECT, gm,i,j,m;
char c[8][8],s[1];  // needed to delcare 's' as string inorder to use it with outtextxy()
initgraph(&gd,&gm,"..\\bgi");
printf("Enter a Character:");
scanf("%s",s);
clearviewport();
outtextxy(1,1,s);
for(i=0;i<textwidth("S");i++)      // any  capital character can be given instead of S
{
for(j=0;j<textheight("S");j++)
{
c[i][j]=getpixel(i,j);
}
}
printf("Enter the size to enlarge the inputted character \n");
scanf("%d",&m);
for(i=0;i<8;i++)
{
for(j=0;j<8;j++)
{
setfillstyle(SOLID_FILL,c[i][j]);
bar(100+(i*m),100+(j*m),100+(i+1)*m,100+(j+1)*m);
}
}
getch();
closegraph();
}


Sample input :
                       Enter a Character: A
                       Enter the size to enlarge the inputted character: 30

1 comment:

  1. Can you please Explain the working of functions and variables in Details?

    ReplyDelete