You are on page 1of 10

Terna Engineering College

Computer Engineering Department


Program: Sem IV

Course: Computer Graphics

Faculty: Sneha bendale

LAB Manual

PART A

(PART A : TO BE REFFERED BY STUDENTS)

Experiment No.12

A.1 Aim:

Character Generation : Bit Map method and Stroke Method

A.2 Prerequisite:
1. C Language.
2. Geometric Concepts.
3. Concept of 2D and 3Dbasic Transformations.
4. Projection Concepts.

A.3 Outcome:
After successful completion of this experiment students will be able to,

Apply Character Generation techniques

A.4 Theory and Procedure:


Bitmap Font/ Bitmapped Font: Character Generation
A simple method for representing the character shapes in a particular typeface is to
use rectangular grid patterns.
The figure below shows the pattern for the particular letter.

When the pattern in the figure copied to the area of the frame buffer, the 1 bits
designate which pixel positions to displayed on the monitor.
Bitmap fonts the simplest to define and display as character grid only need to be
mapped to a framebuffer position.
Bitmap fonts require more space because each variation (size and format) must
stored in a font cache.
It possible to generate different size and other variation from one set but this
usually does not produce the good result.
Outline Font: Character Generation

In this Character Generation method, a character generated using curve section and
straight line as combine assembly. The figure shows how it generated.
To display the character shown in the figure we need to fill interior region of the
character.
This method requires less storage since each variation does not require a distinct
font cache.
We can produce boldface, italic, or different sizes by manipulating the curve
definitions for the character outlines.
But this will take more time to process the outline fonts because they must scan
converted into the frame buffer.
Stroke Method: Character Generation
It uses small line segments to generate a character.
The small series of line segments drawn like a stroke of a pen to form a character as
shown in the figure.
We can generate our own stroke method by calling line drawing algorithm.
Here it is necessary to decide which line segments are needs for each character and
then draw that line to display character.
It supports scaling by changing a length of the line segment.

Starburst Method: Character Generation

In this Character Generation method, a fixed pattern of line segments used to


generate characters.
As shown in the figure there are 24 line segments.
We highlight those lines which are necessary to draw a particular character.
The pattern for the particular character stored in the form of 24-bit code. In which
each bit represents the corresponding line having that number.
That code contains 0 or 1 based online segment need to highlight. We put bit value
1 for highlighted line and 0 for other lines.
Code for letter V is
10011100001001100000000
This technique not used now a days because:
It requires more memory to store 24 bit code for single character.
Moreover, It requires conversion from code to character.
It doesn’t provide curve shapes.
For example

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
intgd=DETECT,gm,i,j;
int a[20][20]=

{{0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,0,0}, 
{0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,1,0}, 
{0,1,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,1}, 
{1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0}, 
{1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0}, 
{1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,0}, 
{1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0}, 
{0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0}, 
{0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,0}, 
{0,0,0,1,1,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0}};

initgraph(&gd,&gm,"c:\\tc\\bgi");
for(i=0;i<19;i++)

for(j=0;j<19;j++)

if(a[i][j]==1) 
putpixel(100+j,200+i,WHITE); 


getch();
}
PART B

(PART B : TO BE COMPLETED BY STUDENTS)

Roll No. C14 Name: Pawan Bhadouria


Class : SE_Comps Batch : C1
Date of Experiment: Date of Submission
Grade :

B.1 Document created by the student:

 BITMAP Method :-

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
intgd=DETECT,gm,i,j;
int a[20][20]=

{{0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,0,0}, 
{0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,1,0}, 
{0,1,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,1}, 
{1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0}, 
{1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0}, 
{1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,0}, 
{1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0}, 
{0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0}, 
{0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,0}, 
{0,0,0,1,1,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0}};

initgraph(&gd,&gm,"c:\\tc\\bgi");
for(i=0;i<19;i++)

for(j=0;j<19;j++)

if(a[i][j]==1) 
putpixel(100+j,200+i,WHITE); 


getch();
}

Stroke method -

#include <stdio.h>
#include <conio.h>
#include <graphics.h>
void main()
{
inti,j,k,x,y;
intgd=DETECT,gm;//DETECT is macro defined in graphics.h
/* ch1 ch2 ch3 ch4 are character arrays that display alphabets */
int ch1[][10]={ {1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1},
{0,0,0,0,1,1,0,0,0,0},
{0,0,0,0,1,1,0,0,0,0},
{0,0,0,0,1,1,0,0,0,0},
{0,0,0,0,1,1,0,0,0,0},
{0,0,0,0,1,1,0,0,0,0},
{0,1,1,0,1,1,0,0,0,0},
{0,1,1,0,1,1,0,0,0,0},
{0,0,1,1,1,0,0,0,0,0}};
int ch2[][10]={ {0,0,0,1,1,1,1,0,0,0},
{0,0,1,1,1,1,1,1,0,0},
{1,1,0,0,0,0,0,0,1,1},
{1,1,0,0,0,0,0,0,1,1},
{1,1,0,0,0,0,0,0,1,1},
{1,1,0,0,0,0,0,0,1,1},
{1,1,0,0,0,0,0,0,1,1},
{1,1,0,0,0,0,0,0,1,1},
{0,0,1,1,1,1,1,1,0,0},
{0,0,0,1,1,1,1,0,0,0}};
int ch3[][10]={ {1,1,0,0,0,0,0,0,1,1},
{1,1,0,0,0,0,0,0,1,1},
{1,1,0,0,0,0,0,0,1,1},
{1,1,0,0,0,0,0,0,1,1},
{1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1},
{1,1,0,0,0,0,0,0,1,1},
{1,1,0,0,0,0,0,0,1,1},
{1,1,0,0,0,0,0,0,1,1},
{1,1,0,0,0,0,0,0,1,1}};
int ch4[][10]={ {1,1,0,0,0,0,0,0,1,1},
{1,1,1,1,0,0,0,0,1,1},
{1,1,0,1,1,0,0,0,1,1},
{1,1,0,1,1,0,0,0,1,1},
{1,1,0,0,1,1,0,0,1,1},
{1,1,0,0,1,1,0,0,1,1},
{1,1,0,0,0,1,1,0,1,1},
{1,1,0,0,0,1,1,0,1,1},
{1,1,0,0,0,0,1,1,1,1},
{1,1,0,0,0,0,0,0,1,1}};
initgraph(&gd,&gm,"D:\\TC\\BGI");//initialize graphic mode
setbkcolor(LIGHTGRAY);//set color of background to darkgray
for(k=0;k<4;k++)
{
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
if(k==0)
{
if(ch1[i][j]==1)
putpixel(j+250,i+230,RED);
}
if(k==1)
{
if(ch2[i][j]==1)
putpixel(j+300,i+230,RED);
}
if(k==2)
{
if(ch3[i][j]==1)
putpixel(j+350,i+230,RED);
}
if(k==3)
{
if(ch4[i][j]==1)
putpixel(j+400,i+230,RED);
}
}
delay(200);
}
}
getch();
closegraph();
}
B.3 Observations and learning:

B.4 Conclusion:

Hence we had successfully Applied Character Generation techniques .

B.5 Question of Curiosity

Q.1]Discuss different advantages and disadvantages of character generation techniques.

Ans :-

Advantages :-
1. Allows you to roll another dice once you have finished rolled the initial eight and
substitute one of your initial rolls.  The new number can not be lower than your
lowest initial roll.

Disadvantages :-

1. Advantageous traits, called advantages, help the player move through the


campaign setting or adventure. These include social traits, character wealth and
special abilities (see Chapter 2) and may be purchased with character points.

************************

You might also like