Date post: | 21-Apr-2015 |
Category: |
Documents |
Upload: | sharvari-kapdi |
View: | 104 times |
Download: | 13 times |
GRAPHICS PRIMITIVES
DISPLAY DEVICES
PRIMITIVE OPERATIONS
DISPLAY FILE INTERPRETER
NORMALISED DEVICED COORDINATES
DISPLAY FILE STRUCTRURE AND ALGORITHMS
TEXT AND LINE STYLE PRIMITIVES
PRESENTED BY
NAME ROLL NO
TULIKA BHARDWAJ 04
SHARVARI KAPDI 19
MANOJ SHRIWASTAVA 48
ROHIT KOUL 22
PRIMITIVE OPERATIONS
Graphics system offer a similar set of graphics primitive commands.
The first primitive command we shall consider is that for drawing s line segment.
COMMANDS:
LINE-ABS-2(X,Y)
LINE-REL-2(DX,DY)
MOVE-ABS-2(X,Y)
MOVE-REL-2(DX,DY)
DISPLAY FILE INTERPRETER
It contain the information necessary to construct the picture.
The information will be in the form of instructions such as “draw a line” or “move a line”.
Each instructions indicates a MOVE or a LINE, action for the display device.
We use display file interpreter to convert these instructions into actual images.
DISPLAY FILE AND INTERPRETER
INTERPRETER
USER PROGRAM
DISPL-AY
FILEDISPLAY
FEATURES:
Portability
Interpreter converts standard display instructions to the actions of the particular device.
Such files of imaging instructions are called as metafiles
UNIVERSITY QUESTIONS:
Create a display file for the following images display device having dimensions Xmin=10,Ymin=7,Xmax=35,Ymax=42
(29,31)
(32,15)
(15,18)
(16,15)
(22,10)
(5,18)
(5,10)
(13,31)
Xmin,Ymin
Xmax,Ymax
NORMALIZED DEVICE COORDINATES:
Different display devices may have different screen sizes as measured in pixel.
The device independent units are called normalized device coordinates.
In these units the screen measures 1 unit wide and 1 unit height.
(0,1)(1,1)
(0,0) (1,0)
CONTD:
Suppose that for the actual display the index of the leftmost pixel is WIDTH-START and there are WIDTH pixels in the horizontal direction.
Suppose also that the bottommost pixel is HEIGHT-START and the number of pixels in the vertical direction is HEIGHT
CALCULATING ACTUAL COORDINATES
For horizontal dirction: Xs=WIDTH* Xn +WIDTH -START
For vertical direction: Ys =HEIGHT*Yn+HEIGHT- START
UNIVERSITY QUESTION:
Represent the given image in normalized coordinates. Consider the current boundary parameters of the screen be Xmin=10,Ymin=10,Xmax=250,Ymax=250
(100,80)
(150,100)(130,100)
(130,200)
(50,100)(70,100)
(70,200)
DISPLAY FILE STRUCTURE
Each display file consists of two parts.o Operation code (opcode) :- It indicates what type
of command it is (e.g. LINE or MOVE).o Operand :- They represent the coordinates of a
point (x,y).
To store the instruction we use three separate arrays. One for the operation code (DF-OP). One for the X- coordinate (DF-X). One for the Y- coordinate (DF-Y).
The Display must be large enough to hold all the commands needed to create our image.
ALGORITHM PUT-POINT(OP ,X ,Y)
Place an instruction into the display file
Arguments OP , X,Y the instruction to be entered
Global DF-OP,DF-X,DF-Y, the three display file
arrays.
FREE the position of the next free
cell.
Constant DFSIZE the length of the display-file
arrays.
Begin
IF FREE> DFSIZE THEN RETURN ERROR ’DISPLAY-FILE FULL’;
DF-OP[FREE]<- OP; DF-X[FREE]<-X; DF-Y[FREE]<-Y; FREE<-FREE+1; RETURN; END This algorithm stores the operation code and
the coordinates of the specified position in the display file. The pointer FREE to the next free cell is incremented so that it will be in the correct position for the next entry.
ALGORITHM FOR GET-POINT(NTH,OP,X,Y)
Retrieve the nth instruction from the display file OP<-DF-OP[NTH];
X<-DF-X[NTH]; Y<-DF-Y[NTH]; RETURN; END;
DISPLAY FILE ALGORITHMS
BEGIN FRAME-PEN-X <- MAX(WIDTH-START,
MIN(WIDTH-END, X*WIDTH+WIDTH-START));
FRAME-PEN-Y <- MAX(HEIGHT-START, MIN(HEIGHT-END,
Y*HEIGHT+HEIGHT-START));
RETURN;END;
In this algorithm we see the formula for converting the normalised coordinates values of arguments into actual screen coordinates.
The MAX,MIN functions have been added to formula because they prevent it from ever generating a valueoutside the bonds of the actual display.
DISPLAY CONTROL
In order to show the picture describe in the display file, we might have to do three things To clear the current display. To interpret the display file. On some devices an explicit action is requierd to
show the content of the frame buffer on some devices(eg. Line printer and standard CRT terminals).
It is not necessary to clear the display everytime we interpret the display file .
Sometimes we just have to make some additions in the image so there is no need to clear the image and redraw it again.
CONTD:
We handle clearing of the frame by using a flag. We use a true value to indicate that the screen should be cleared and false value to mean that the display file instruction may be drawn on top of the old image.
THANK YOU