Anda di halaman 1dari 118

1

Unit - 1
Father of Computer Graphics
Ivan Sutherland
Output Primitives
Line Drawing Algorithms
DDA Algorithm
Midpoint Algorithm
Bersenhems Algorithm
Circle Drawing Algorithms
Midpoint Circle Algorithm
Antialiasing
Fill-Area Algorithms
2
3
Describes the geometry of objects and
typically referred to as geometric
primitives.
Examples: point, line, text, filled region,
images, quadric surfaces, spline curves
Each of the output primitives has its own
set of attributes.
The basic objects out of which a graphics
display is created are called Output
Primitives
Points
Attributes: Size, Color.
glPointSize(p);
glBegin(GL_POINTS);
glVertex2d(x1, y1);
glVertex2d(x2, y2);
glVertex2d(x3, y3);
glEnd()

Lines
Attributes: Color, Thickness, Type
glLineWidth(p);
glBegin(GL_LINES);
glVertex2d(x1, y1);
glVertex2d(x2, y2);
glVertex2d(x3, y3);
glVertex2d(x4, y4);
glEnd()

Output Primitive Attributes
Point Size
Color
Line Thickness (1pt, 2pt )
Type (Dashed, Dotted, Solid)
Color
7
8
Rasterization Problem: Given only the two end points, how
to compute the intermediate pixels, so that the set of pixels
closely approximate the ideal line.
The digital differential analyser
(DDA) algorithm takes an
incremental approach in order to
speed up scan conversion
Simply calculate y
k+1
based on
y
k

The original differential
analyser was a physical
machine developed by
Vannevar Bush at MIT in the
1930s in order to solve
ordinary differential equations.
m
x
y
=
A
A
x y
0 1
1 4
2 7
3 10
4 13
5 16
m y
x 1
=
A
A
i.e. y = 3x + 1 m = 3
Do not use
y = 3x + 1
to calculate y.
Use m
Uses differential equation of the line : m
If slope then increment x in steps of 1
pixel and find corresponding y-values.
If slope then increment y in steps of 1
pixel and find corresponding x-values.













step through in x step through in y

if |m| s 1
x
i+1
= x
i
- 1
y
i+1
= y
i
- m
if |m| > 1
y
i+1
= y
i
+ 1
x
i+1
= x
i
+ 1/m
Left
Right
Left
Right

+ =
+ =
s s
+ =
+
+
3
1
1
1 3
1
1
1 0
1
i i
i i
y y
x x
m
x y
x y round(y)
0 1 1
1 4/3 1
2 5/3 2
3 2 2
4 7/3 2
5 8/3 3
6 3 3
7 10/3 3
8 11/3 4
18
8
7
6
5
4
3
2
1
0
0 1 2 3 4 5 6 7 8
y
x

=
=
<
+ =
+
+
) (
1
1
8 3
3
1
1
1
i i
i i
x x
y y
m
x y
y x round(x
)
8 0 0
7 1/3 0
6 2/3 1
5 1 1
4 4/3 1
3 5/3 2
2 2 2
1 7/3 2
0 8/3 3
19
8
7
6
5
4
3
2
1
0
0 1 2 3 4 5 6 7 8
y
x
20
7
6
5
4
3
2
1
0
0 1 2 3 4 5 6 7 8 9 10 11 12
21



p
p
p
n
n x
x
1 + A
= A
22




Ay
p
= mAx
p

y
k
= y
0
+ round(kAy
p
)
p
k
= (kAx
p
)(2Ay) round(kAy
p
)(2Ax) + 2Ay Ax
4
4
18
4
1 4 15
= =
+
= A
p
x
23
Jack Bresenham worked for
27 years at IBM before
entering academia.
Bresenham developed his
famous algorithms at IBM
in the early 1960s

What you need to know about Bresenham LDA
1) Why we use it
2) Major idea of integer-izing a decision point
3) How this reduces things to just integer form.
(17,8)
(2,2)
(0,0)
(18,0)
(0,9)
Basis of the algorithm:






From start position decide A or B next
A
B
Start position
oFor a given value of x
o One pixel lies at distance above the line, and
o One pixel lies at distance below the line
True line


If d
i
< 0, then closest pixel is below true line (s
i

smaller)
If d
i
> 0, then closest pixel is above true line (t
i

smaller)


We must calculate the new values for as we move
along the line.
) 2 or 5 . 0 (i.e. 0.5 (slope) gradient Let dx dy
dx
dy
< < <
29
3dy
2dy
dy
4dy
x
1
x
2
x
3
x
4
x
5
x
0
y
0
y
1
y
2
y
3
y
5
For a line with gradient 1
d
0
= 2dy dx
if d
i
< 0 then y
i+1
= y
i
d
i+1
= d
i
+ 2dy
if d
i
0 then y
i+1
= y
i
+ 1

d
i+1
= d
i
+ 2(dy dx)
x
i+1
= x
i
+ 1
For a line with gradient > 1
d
0
= 2dx dy
if d
i
< 0 then x
i+1
= x
i
d
i+1
= d
i
+ 2dx
if d
i
0 then x
i+1
= x
i
+ 1

d
i+1
= d
i
+ 2(dx dy)
y
i+1
= y
i
+ 1
Note: For |m| 1 the constants 2dy and 2(dy-dx) can be calculated
once,
so the arithmetic will involve only integer addition and subtraction.
19
18
17
16
15
14
13
12
11
10
20 21 22 23 24 25 26 27 28 29 30 31 32
31
(20,10)
(30,18)
i d
i
(x
i+1
,y
i+1
)
0 6 (21,11)
1 2 (22,12)
2 -2 (23,12)
3 14 (24,13)
4 10 (25,14)
5 6 (26,15)
6 2 (27,16)
7 -2 (28,16)
8 14 (29,17)
9 10 (30,18)
LineBres( x0, y0, x1, y1) // line for |m| < 1
{
dx = abs(x1 x0), dy = abs(y1 y0);
d = 2 * dy dx, twoDy = 2 * dy, twoDyMinusDx = 2 * (dy
dx);
x, y;

(x0 > x1) { // determines which point to use as start, which
as end
x = x1;
y = y1;
x1 = x0;
}
{
x = x0;
y = y0;
}
setPixel(x,y);

(x < x1) {
x++;
(d < 0) d += twoDy;
{
y++;
d += twoDyMinusDx;
}
setPixel(x, y);
}
}
32
Special cases can be handled separately
Horizontal lines (Ay = 0)
Vertical lines (Ax = 0)
Diagonal lines (|Ax| = |Ay|)
directly into the frame-buffer without processing
them through the line-plotting algorithms.
33
Raster:
Pixel:
Scan Line:
Refresh buffer frame buffer:
intensity
painted
scan line
Intensity range for pixel positions
depends on the capability of the
raster system.
A black-and-white system: each
screen point is either on or off, so
only one bit per pixel is needed to
control the intensity of screen
positions.
On a black-and-white system
with one bit per pixel, the frame
buffer is called bitmap.

For system with multiple bits per
pixel, the frame buffer is called
pixmap.
Sometimes, refresh rates
are described in unit of
cycles per second, or Hertz
(HZ)
Refreshing on raster scan
displays is carried out at
the rate 60 to 80 frame per
second.
Horizontal retrace: The return
to the left of the screen, after
refreshing each scan line.
Vertical retrace: At the end of each frame
(displayed in 1/80
th
to 1/60
th
of a second)
the electron beam returns to the top left
corner of the screen to begin the next
frame.
A final stage in the implementation
procedures for line segments and other
objects is to set the frame-buffer color
values.
scan-conversion algorithms generate pixel
positions at successive unit intervals,
incremental operations can also be used to
access the frame buffer efficiently at each
step of the scan-conversion process.


suppose the frame buffer array is addressed in row major
order and that pixel positions are labeled from (0, 0) at the
lower-left screen corner to (x max , y max ) at the top-right
corner.
For a bilevel system (one bit per pixel), the frame-buffer bit
address for pixel position ( x , y ) is calculated as



Moving across a scan line, we can calculate the frame-buffer address for the
pixel at ( x + 1, y ) as the following offset from the address for position ( x , y ):
Stepping diagonally up to the next scan line from ( x , y ),we get to the frame-buffer
address of ( x + 1, y + 1) with the calculation
where the constant x max + 2 is precomputed once for all line segments.
Each of the address calculations involves only a single integer addition.


Methods for implementing these procedures depend on the capabilities of a
particular system and the design requirements of the software package.
With systems that can display a range of intensity values for each pixel, frame-
buffer address calculations include pixel width (number of bits), as well as the
pixel screen location.
Line
Defined by two endpoint coordinates
(one line segment)
glBegin(GL_LINES );
glVertex2i( 180, 15 );
glVertex2i( 10, 145 );
glEnd();
If several vertices, a line is drawn between the first and
second, then a separate one between the third and the fourth,
etc. (isolated vertices are not drawn).

Polyline
Defined by line connecting all the points
glBegin(GL_LINE_STRIP );
glVertex2i( 180, 15 );
glVertex2i( 10, 145 );
glVertex2i( 100, 20 );
glVertex2i( 30, 150 );
glEnd();
Draws a line between vertex 1 and vertex 2
then between vertex 2 and vertex 3
then between vertex 3 and vertex 4.

Polyline
In addition to GL_LINE_STRIP, adds a line between the last
vertex and the first one
glBegin(GL_LINE_LOOP );
glVertex2i( 180, 15 );
glVertex2i( 10, 145 );
glVertex2i( 100, 20 );
glVertex2i( 30, 150 );
glEnd();
Draws a line between vertex 1 and vertex 2
then between vertex 2 and vertex 3
then between vertex 3 and vertex 4
then between vertex 4 and vertex 1.
A circle is defined as the set of points that are all at a given
distance r from a center point (x
c
, y
c
).



For any circle point (x, y), this distance is expressed by the
Equation
(x x
c
)
2
+ (y y
c
)
2
= r
2
We calculate the points by stepping along the x-axis in unit
steps from x
c
-r to x
c
+r and calculate y values as
There are some problems with this approach:
1. Considerable computation at each step.
2. Non-uniform spacing between plotted pixels as in this
Figure.

Problem 2 can be removed using the polar form:
x = x
c
+ r cos
y = y
c
+ r sin

using a fixed angular step size, a circle is plotted with
equally spaced points along the circumference.
Problem 1 can be overcome by considering the
symmetry of circles as in Figure 3.
But it still requires a good deal of computation time.





Efficient Solutions
Midpoint Circle Algorithm
To apply the midpoint method, we define a circle function:



Any point (x,y) on the boundary of the circle with radius r
satisfies the equation f
circle
(x, y)= 0.
If the points is in the interior of the circle, the circle
function is negative.
If the point is outside the circle, the circle function is
positive.

To summarize, the relative position of any point (x,y) can
be determined by checking the sign of the circle function:





The circle function tests in (3) are performed for the mid
positions between pixels near the circle path at each
sampling step. Thus, the circle function is the decision
parameter in the midpoint algorithm, and we can set up
incremental calculations for this function as we did in the
line algorithm.
Figure 4 shows the midpoint between the two candidate
pixels at sampling position x
k
+1. Assuming we have just
plotted the pixel at (x
k
, y
k
), we next need to determine
whether the pixel at position (x
k
+1, y
k
) or the one at
position (x
k
+1, y
k
1) is closer to the circle.
Our decision parameter is the circle function (2)
evaluated at the midpoint between these two pixels:

If p
k
< 0, this midpoint is inside the circle and the pixel on
scan line y
k
is closer to the circle boundary.
Otherwise, the midpoint is outside or on the circle
boundary, and we select the pixel on scan line y
k
1.
Successive decision parameters are obtained using
incremental calculations.
We obtain a recursive expression for the next decision parameter by
evaluating the circle function at sampling position x
k+1
+1 = x
k
+ 2













where y
k+1
is either y
k
or y
k-1
,depending on the sign of p
k
.
Increments for obtaining p
k+1
are either
2x
k+1
+1 (if p
k
is negative) or
2x
k+1
+1 2y
k+1
(if p
k
is positive)
Evaluation of the terms 2x
k+1
and 2y
k+1
can also be
done incrementally as:

At the start position (0, r), these two terms (2x, 2y) have
the values 0 and 2r, respectively.
Each successive value is obtained by adding 2 to the
previous value of 2x and subtracting 2 from the previous
value of 2y.

The initial decision parameter is obtained by evaluating
the circle function at the start position (x
0
, y
0
)=(0, r):

If the radius r is specified as an integer, we can simply
round p
0
to




since all increments are integers.

As in Bresenhams line algorithm, the midpoint method
calculates pixel positions along the circumference of a
circle using integer additions and subtractions, assuming
that the circle parameters are specified in screen
coordinates. We can summarize the steps in the midpoint
circle algorithm as follows.

70
Can also use Bresenham to draw circles.

Use 8-fold symmetry




Choices for
Next pixel
M
E
SE
Previous
Pixel

Choices for
Current pixel
71
Implicit form for a circle is:





) 3 2 ( chosen is E If
) 5 2 2 ( chosen is SE If
+ + =
+ + =
p old new
p p old new
x d d
y x d d
Functions are linear equations in terms of (xp,yp)
Termed point of evaluation

2 2 2
) ( ) ( ) , ( r y y x x y x f
c c
+ =
72
Explicit form of line
Inefficient, difficult to control.
Parametric form of line.
Express line in terms of parameter t
DDA algorithm
Implicit form of line
Only need to test for side of line.
Bresenham algorithm.
Can also draw circles.
Ellipse A modified circle whose radius varies from a
maximum value in one direction (major axis) to a
minimum value in the perpendicular direction (minor
axis).
73
P=(x,y)
F
1
F
2
d
1
d
2
The sum of the two distances d
1
and d
2
, between the
fixed positions F
1
and F
2
(called the foci of the ellipse)
to any point P on the ellipse, is the same value, i.e.
d
1
+ d
2
= constant
Expressing distances d
1
and d
2
in terms of the focal
coordinates F
1
= (x
1
, x
2
) and F
2
= (x
2
, y
2
), we have:







Cartesian coordinates:

Polar coordinates:
2 2 2 2
1 1 2 2
( ) ( ) ( ) ( ) constant x x y y x x y y + + + =
2
2
1
c c
x y
x x y y
r r
| |
| |

+ =
|
|
|
\ .
\ .
74
r
y
r
x
cos
sin
c x
c y
x x r
y y r
u
u
= +
= +
Symmetry between quadrants
Not symmetric between the two octants of a
quadrant
Thus, we must calculate pixel positions along the
elliptical arc through one quadrant and then we
obtain positions in the remaining 3 quadrants by
symmetry
75
(x, y)
(-x, y)
(x, -y)
(-x, -y)
r
x
r
y
Decision parameter:
2 2 2 2 2 2
( , )
ellipse y x x y
f x y r x r y r r = +
0 if ( , ) is inside the ellipse
( , ) 0 if ( , ) is on the ellipse
0 if ( , ) is outside the ellipse
ellipse
x y
f x y x y
x y
<

= =

>

76
1
Slope = -1
r
x
r
y 2
2
2
2
2
y
x
r x
dy
Slope
dx r y
= =
Starting at (0, r
y
) we take unit steps in the x direction
until we reach the boundary between region 1 and
region 2. Then we take unit steps in the y direction
over the remainder of the curve in the first quadrant.
At the boundary


therefore, we move out of region 1 whenever
77
1
Slope = -1
r
x
r
y 2
2 2
1 2 2
y x
dy
r x r y
dx
= =
2 2
2 2
y x
r x r y >
y
i
y
i
-1
x
i
x
i
+1 x
i
+2
78
Midpoint
Assuming that we have just plotted the pixels at (x
i
, y
i
).
The next position is determined by:
1
2
2 2 2 2 2 2
1
2
1 ( 1, )
( 1) ( )
i ellipse i i
y i x i x y
p f x y
r x r y r r
= +
= + +
If p1
i
< 0 the midpoint is inside the ellipse y
i
is closer
If p1i 0 the midpoint is outside the ellipse y
i
1 is
closer
At the next position [x
i+1
+ 1 = x
i
+ 2]



OR


where y
i+1
= y
i
or y
i+1
= y
i
1
79
1
1 1 1 2
2 2 2 2 2 2
1
1 2
1 ( 1, )
( 2) ( )
i ellipse i i
y i x i x y
p f x y
r x r y r r
+ + +
+
= +
= + +
2 2 2 2 2 2
1 1
1 1 2 2
1 1 2 ( 1) ( ) ( )
i i y i y x i i
p p r x r r y y
+ +
(
= + + + +

Decision parameters are incremented by:



Use only addition and subtraction by obtaining


At initial position (0, r
y
)
80
2 2
1
2 2 2
1 1
2 if 1 0
2 2 if 1 0
y i y i
y i y x i i
r x r p
increment
r x r r y p
+
+ +

+ <

=

+ >

2 2
2 and 2
y x
r x r y
2
2 2
2 2 2 2 2
1 1
0 2 2
2 2 2
1
4
2 0
2 2
1 (1, ) ( )

y
x x y
ellipse y y x y x y
y x y x
r x
r y r r
p f r r r r r r
r r r r
=
=
= = +
= +
Over region 2, step in the negative y direction and midpoint
is taken between horizontal pixels at each step.
81
y
i
y
i
-1
x
i
x
i
+1 x
i
+2
Midpoint
Decision parameter:
1
2
2 2 2 2 2 2
1
2
2 ( , 1)
( ) ( 1)
i ellipse i i
y i x i x y
p f x y
r x r y r r
= +
= + +
If p2
i
> 0 the midpoint is outside the ellipse x
i
is closer
If p2i 0 the midpoint is inside the ellipse x
i
+ 1 is
closer
At the next position [y
i+1
1 = y
i
2]



OR


where x
i+1
= x
i
or x
i+1
= x
i
+ 1
82
1
1 1 1 2
2 2 2 2 2 2
1
1 2
2 ( , 1)
( ) ( 2)
i ellipse i i
y i x i x y
p f x y
r x r y r r
+ + +
+
= +
= + +
2 2 2 2 2
1 1
1 1 2 2
2 2 2 ( 1) ( ) ( )
i i x i x y i i
p p r y r r x x
+ +
(
= + + + +

Decision parameters are incremented by:





At initial position (x
0
, y
0
) is taken at the last
position selected in region 1
83
2 2
1
2 2 2
1 1
2 if 2 0
2 2 if 2 0
x i x i
y i x i x i
r y r p
increment
r x r y r p
+
+ +

+ >

=

+ s

1
0 0 0 2
2 2 2 2 2 2
1
0 0 2
2 ( , 1)
( ) ( 1)
ellipse
y x x y
p f x y
r x r y r r
= +
= + +
1. Input r
x
, r
y
, and ellipse center (x
c
, y
c
), and obtain the
first point on an ellipse centered on the origin as
(x
0
, y
0
) = (0, r
y
)
2. Calculate the initial parameter in region 1 as


3. At each x
i
position, starting at i = 0, if p1
i
< 0, the
next point along the ellipse centered on (0, 0) is (x
i
+
1, y
i
) and


otherwise, the next point is (x
i
+ 1, y
i
1) and


and continue until
84
2 2 2
1
0 4
1
y x y x
p r r r r = +
2 2
1 1
1 1 2
i i y i y
p p r x r
+ +
= + +
2 2 2
1 1 1
1 1 2 2
i i y i x i y
p p r x r y r
+ + +
= + +
2 2
2 2
y x
r x r y >
4. (x
0
, y
0
) is the last position calculated in region 1.
Calculate the initial parameter in region 2 as

5. At each y
i
position, starting at i = 0, if p2
i
> 0, the next
point along the ellipse centered on (0, 0) is (x
i
, y
i
1) and

otherwise, the next point is (x
i
+ 1, y
i
1) and

Use the same incremental calculations as in region 1.
Continue until y = 0.
6. For both regions determine symmetry points in the other
three quadrants.
7. Move each calculated pixel position (x, y) onto the
elliptical path centered on (x
c
, y
c
) and plot the coordinate
values
x = x + x
c
, y = y + y
c
85
2 2 2 2 2 2
1
0 0 0 2
2 ( ) ( 1)
y x x y
p r x r y r r = + +
2 2
1 1
2 2 2
i i x i x
p p r y r
+ +
= +
2 2 2
1 1 1
2 2 2 2
i i y i x i x
p p r x r y r
+ + +
= + +
86
i p
i
x
i+1
, y
i+1
2r
y
2
x
i+1
2r
x
2
y
i+1
0 -332 (1, 6) 72 768
1 -224 (2, 6) 144 768
2 -44 (3, 6) 216 768
3 208 (4, 5) 288 640
4 -108 (5, 5) 360 640
5 288 (6, 4) 432 512
6 244 (7, 3) 504 384
r
x
= 8 , r
y
= 6
2r
y
2
x = 0 (with increment 2r
y
2
= 72)
2r
x
2
y = 2r
x
2
r
y
(with increment -2r
x
2
= -128)
Region 1
(x
0
, y
0
) = (0, 6)
2 2 2
1
0 4
1 332
y x y x
p r r r r = + =
Move out of region 1 since
2r
y
2
x > 2r
x
2
y
6

5

4

3

2

1

0

0 1 2 3 4 5 6 7 8
87
i p
i
x
i+1
, y
i+1
2r
y
2
x
i+1
2r
x
2
y
i+1
0 -151 (8, 2) 576 256
1 233 (8, 1) 576 128
2 745 (8, 0) - -
Region 2
(x
0
, y
0
) = (7, 3) (Last position in region 1)
1
0 2
2 (7 , 2) 151
ellipse
p f = + =
Stop at y = 0
Definition
Line Attribute
Curve Attribute
COLOR AND GRAY SCALE LEVEL
AREA FILLED ATTRIBUTE
Text and Characters

30/9/2008 Lecture 2 88
30/9/2008 Lecture 2 89
Definition
Parameter that affects the way a primitive will be
displayed
Line Attribute
. Type
. Width
. Color
. Pen & Brush
30/9/2008 Lecture 2 90
Type
. Solid
. Dotted very short dash with spacing equal
to
or greater than dash itself
. Dashed displayed by generating an
interdash spacing
Pixel count for the span and interspan length is
specified
by the mask . Ex. 111100011110001111
Note : Fixed pixel with dashes can produce unequal length
dashes. It depend on line orientation. So, need to adjust
the number of plotted pixels for different slopes.
30/9/2008 Lecture 2 91
Width
. Specify in pixels and proportion of a standard line width.
. Thicker line can be produced by.
. Adding extra pixel vertically when |m| < 1
. Adding extra pixel horizontally when |m| > 1
. Issues:
. Line have different thickness on the slope
. Problem with
. End of the line
. Joining the two lines (polygon)
30/9/2008 Lecture 2 92
Width
30/9/2008 Lecture 2 93
30/9/2008 Lecture 2 94
Pen and Brush
. The selected pen or brush determine the way a line will be drawn.
. Pens and brushes have size, shape, color and pattern attribute.
. Pixel mask is applied in both of them.
30/9/2008 Lecture 2 95
Similar to line : type + width
Thicker curves can be produced by:
1. Plotting additional pixel
2. Filling the space between two concentric circles.
3. Using thicker pen or brush
30/9/2008 Lecture 2 96
30/9/2008 Lecture 2 97
Width
Color
Colors are represented by colors codes which are
positive integers.

Color information is stored in frame buffer or in
separate table and use pixel values as index to the
color table.

Two ways to store color information :
1. Direct
2. Indirect
30/9/2008 Lecture 2 98
Direct
30/9/2008 Lecture 2 99
Indirect
30/9/2008 Lecture 2 100
Exercise:

What is the size of frame buffer required for the following cases:

Case 1 (Direct): Resolution of 1024 * 1024 with 24 bits per
pixel

Case 2 (Indirect): Same resolution with 8 bit per pixel that
indexed out of 16 million available colors


Conclusion

CLUT is good for storage but cant give a very high resolution picture.


30/9/2008 Lecture 2 101
30/9/2008 Lecture 2 102
30/9/2008 Lecture 2 103
.Apply for monitor that have no color
.Shades of grey (white->light grey->dark grey->black)
.Color code mapped onto grayscale codes
.2 bits can give 4 level of grayscale
.8 bits per pixel will allow 256 combination
.Dividing the actual code with 256 will give range of 0 and 1

Ex:
Color code in color display is 118

To map to nearest grayscale then

118/256 = 0.45

light gray



30/9/2008 Lecture 2 104
30/9/2008 Lecture 2 105
. Option for filling a defined region is whether solid , pattern and
colors.

Fill Styles
. Three basic fill styles are:
. hollow with color border.. interior color is same with
background




30/9/2008 Lecture 2 106
. filled with a solid color .. color up to and including the border

pattern .. control by other table
30/9/2008 Lecture 2 107
30/9/2008 Lecture 2 108
. Color-Blended Fill Region

-Soft-fill
- P = tF + (1-t)B where 0 < t < 1
If t < 0.5 , background color contributes more to
the interior color of the region than does the fill
color.

30/9/2008 Lecture 2 109



30/9/2008 Lecture 2 110



30/9/2008 Lecture 2 111



30/9/2008 Lecture 2 112



30/9/2008 Lecture 2 113



30/9/2008 Lecture 2 114
Text and Characters
Very important output primitive
Many pictures require text
Two general techniques used
Bitmapped (raster)
Stroked (outline)
30/9/2008 Lecture 2 115
Each character represented (stored) as a 2-D array
Each element corresponds to a pixel in a
rectangular character cell
Simplest: each element is a bit (1=pixel on, 0=pixel
off)

00111000
01101100
11000110
11000110
11111110
11000110
11000110
00000000
30/9/2008 Lecture 2 116
Each character represented (stored) as
a series of line segments
sometimes as more complex primitives
Parameters needed to draw each stroke
endpoint coordinates for line segments
30/9/2008 Lecture 2 117
Characteristics of Bitmapped Characters
Each character in set requires same amount of
memory to store
Characters can only be scaled by integer scaling
factors
"Blocky" appearance
Difficult to rotate characters by arbitrary angles
Fast (BitBLT)
Characteristics of Stroked Characters
Number of stokes (storage space) depends on
complexity of character
Each stroke must be scan converted more time to
display
Easily scaled and rotated arbitrarily
just transform each stroke
30/9/2008 Lecture 2 118
When each function reference a single attribute that specify exactly
how primitive to be displayed ; then its called
individual (unbundled attribute).

.Bundled attributes is where a set of attributes value can be chosen
by specifying the appropriate index table.

.The table for each primitive that defines group of attribute values is
called bundled table.

.Attribute that can be bundled are:
. Bundled Line Attribute
. Bundled Area-Fill Attribute
. Bundled Text Attribute
. Bundled Marker Attribute

Anda mungkin juga menyukai