Chapter 01
Chapter 01
Chapter 01
The definitions:
● An image-based (or raster) graphic represents the pictures by measuring the color at a predetermined set of
locations (usually a grid).
● For example,Think of a picture taken with a camera: it tells you a color for each point taken on a fixed grid.
● An object-based (or vector) graphic represents the picture by describing the objects in the picture in a
mathematical way.
● For example, list the 2D things (lines, circles). The number and positions of these objects can vary.
1 Image-based often called Raster image Object-based often called Vector image
2 This represent scene using Pixel This represent scene using mathematical way
5 Good for presenting realistic scene This is good for presenting large areas of constant
color.
Pixel:-
1.In Computer graphics pixels, dots, or picture element is a physical point in a
picture.
3.A majority of the pictures that we see on our computer screen are raster
images.
4.The selfie that you click with your mobile phone is another example of a
raster image.
7.We also defined that a pixel can store a value proportional to the light intensity at that particular location.
8. For example,
2 bpp, 22 = 4 colors
3 bpp, 23 = 8 colors
Resolution
If an image has M rows and N columns, then its resolution can be defined as M X N.
VGA : 1640 x 480
SVGA : 800 x 600
XGA : 1024 x 768
SXGA : 1400 x 1050
HD+: 1600 x 900
FHD: 1920 x 1080
Text mode:-
Application:
1.command-line interfaces (terminal)
2.text user interfaces(Turbo c++)
Graphics mode:-
1 When you start a program under MS-DOS, the While when you start a program under windows, the
computer's screen is in character mode computer's screen is in graphics mode.
2 In character mode, every character is drawn as a Whereas in graphic mode, everything is drawn one dot (pixel)
dot pattern at a time
3 In character mode, the usual display configuration Whereas a typical VGA display will show 640 pixels horizontally
allows 80 characters across each row and 25 lines and 480 pixels vertically.
of characters.
4 The characters always have the same font, although Whereas in graphic mode, each pixel can be any of 16 colors
the color of each letter and its background can be
changed.
5 The Characters mode displays are relatively faster. It's Slower as compared to text mode.
6 In character mode, there is no way to show pictures whereas in graphics mode we can display pictures, charts,
graphs very easily
Graphics Pipeline
● Graphics Pipeline is the sequence of steps that OpenGL takes when rendering objects. Vertex attribute and other
data go through a sequence of steps to generate the final image on the screen.
● It is a conceptual model that describes what steps a graphics system needs to perform to render a 3D scene to a 2D
screen.
● Once a 3D model has been created, for instance in a video game or any other 3D computer animation, the graphics
pipeline is the process of turning that 3D model into what the computer displays.
● The model of the graphics pipeline is usually used in real-time rendering.
● Often, most of the pipeline steps are implemented in hardware, which allows for special optimizations.
Working:-
●
Vertex Processing: Process and transform individual vertices & normals.
●
Rasterization: Convert each primitive (connected vertices) into a set of fragments. A fragment can be interpreted as a
pixel with attributes such as position, color, normal and texture.
● Fragment Processing: Process individual fragments.
● Output Merging: Combine the fragments of all primitives (in 3D space) into 2D color-pixel for the display.
Advantage:-
● The process of each primitive (Which is a set of vertices) can be done independently.
● Graphics Pipeline leads fast performance.
Disadvantage:
● Graphics like shadowing,reflection,blending cannot be handled in a physically correct manner.
1.(BMP) is an image file format that can be used to create and store computer
graphics.
2. A bitmap file displays small dots in a pattern that, when viewed from afar,
creates an overall image.
3.A bitmap image is a grid made of rows and columns where a specific cell is
given a value that fills it in or leaves it blank.
4. an image is broken into the smallest possible units (pixels) and then the color
information of each pixel (color depth) is stored in bits that are mapped out in
rows and columns.
5.The complexity of a bitmap image can be increased by varying the color
intensity of each dot or by increasing the number of rows and columns used to
create the image.
6.However, when a user magnifies a bitmap image enough, it eventually becomes pixelated as the dots resolve into
tiny squares of color on a grid.
2.Application of Concept/ Examples in real life:
1.Bitmap Image:-
1.JPEG,PNG,TIFF,GIF.
2.Graphical user interface.
3.Bitmap Image:
Advantage:
● Larger in size than vector based.
● More suitable for complex image
Disadvantage:
● More difficult to convert bitmap to vector graphics.
● Bitmap graphics are affected by resolution.
2.Vector Image:-
1 Pixel are used to form bitmap image Mathematical formula are used to form vector
based image
2. Larger in size than vector based Smaller in size than bitmap based
5. More suitable for complex image Not appropriate for complex images
There are two ways (Random scan and Raster scan) by which we can display an object on the screen
1.Raster Scan:-
1.In a raster scan system, the electron beam is swept across the screen, one row at a time from top to bottom.
2.As the electron beam moves across each row, the beam intensity is turned on and off to create a pattern of
illuminated spots.
3.Picture definition is stored in a memory area called the Refresh Buffer or
Frame Buffer.
4.This memory area holds the set of intensity values for all the screen points.
5.Stored intensity values are then retrieved from the refresh buffer and
“painted” on the screen one row (scan line) at a time as shown in the following
illustration.
6.Each screen point is referred to as a pixel (picture element) or pel.
7.At the end of each scan line, the electron beam returns to the left side of the
screen to begin displaying the next scan line.
3.Random Scan:-
Advantages:
● A CRT has the electron beam directed only to the parts of the screen where an image is to be drawn.
● Produce smooth line drawings.
● High Resolution
Disadvantages:
● Random-Scan monitors cannot display realistic shades scenes.
920×1080 .
8.The resolution of the plasma panel can be up to 512 * 512 pixels now latest 1
Plasma panel:
Advantage:
● High Resolution
● Large screen size is also possible.
● Less Volume
● Less weight
● Flicker Free Display
Disadvantage:
● Poor Resolution
● Wiring requirement anode and the cathode is complex.
● Its addressing is also complex.
2.Application:-
1. digital billboards,Bus no,Railway platform,highway etc.
2.Decorate interiors and exteriors.
3.Advertise brands and products.
Advantages:-
● Longevity
● They light up faster
● Cost Effectiveness
● Durability
● Color
● Eco-friendly
Disadvantage
● High initial cost
● Temperature Sensitive
● Voltage Sensitive
● Eye Strain
Advantage
1.Low cost
2.Low Weight
3.Small size
4.Low power consumption
Disadvantage:-
1. LCDs are temperature-dependent (0-70°C)
2. LCDs do not emit light; as a result, the image has very little contrast.
3. LCDs have no color capability.
4. The resolution is not as good as that of a CRT.
OUTPUT PRIMITIVES
1.The Primitives are the simple geometric functions that are used to generate various Computer Graphics required by the User.
for example,Some most basic Output primitives are point-position(pixel), and a straight line
2.A In raster display, a picture is completely specified by the set of intensities for the pixel positions in the display.
3.At the other extreme, we can describe a picture as a set of complex objects, such as trees and terrain or furniture and walls,
positioned at specified coordinate locations within the scene.
4.Shapes and colors of the objects can be described internally with pixel arrays or with sets of basic geometric structures.
5.such as straight line segments and polygon color areas. The scene is then displayed either by loading the pixel arrays into the
frame buffer.
6.A frame buffer stores the pixel location and other information such as intensity, color of the pixel position that is to be
generated on the screen.
7.Here we start by device-level algorithms for displaying two-dimensional output primitives
1.Point:
The header file graphics.h contains putpixel() function which plots a pixel at location (x, y) of specified color.
Syntax :
putpixel(int x, int y, int color);
where,(x, y) is the location at which pixel is to be put , and color specifie the color of the pixel.
2.Line
Graphics mode:- It is Graphics mode which is a computer display mode that generates image using pixels.DETECT is a macro
defined in "graphics.h" header file
Initgraph():- It initializes the graphics system by loading a graphics driver from disk
Closegraph():- it function closes the graphics mode and deallocates all memory allocated by the graphics system .
#include<stdio.h>
#include<graphics.h>
int main()
{
int gd=DETECT,gm,color,i[]={20,100,120,100,100,120,20,100};
initgraph(&gd,&gm,NULL);
putpixel(20,20,RED);
outtextxy(20,23,"1.Pixel");
line(20,50,100,50);
outtextxy(20,55,"2.Line");
drawpoly(4,i);
outtextxy(20,120,"3.Polygon");
outtextxy(20,120,"3.Polygon");
outtextxy(20,150,"4.Text");
getch();
closegraph();
return 0;
}
Graphics Function.
1.Putpixel
Purpose:-Putpixel function is to draw the pixel on the screen. Pixel is a small dot on the screen.
Syntax:-putpixel(x co-orinate, y co-ordinate,COLOR);
Example: – putpixel(100,100,BLUE);
2.SetbkColor
Purpose:-Setbkcolor function is used to set background color of the screen.
Syntax:-setbkcolor(COLOR);
Example:-setbkcolor(RED);
3.Setlinestyle
Purpose:-setlinestyle function is used to set the current line style, width and pattern
Syntax:-setlinestyle(linestyle, upattern, thickness);
Example:-setlinestyle(SOLID_LINE,1,2);
4.Setcolor
5.Rectangle:-
Purpose:- Rectangle function is used to draw the rectangle on the screen. X1,y1 are the lower left co-ordinates of the rectangle
and the x2,y2 are the upper right co-ordinates of the rectangle.
Syntax:– rectangle(x1,,y1,x2,y2);
Example:– rectangle(100,100,200,200);
6.Textheight
Purpose:-textheight returns the height of a string in pixels.
Syntax:-textheight(STRING);
Example:-i=textheight(“HELLO”);
7.Textwidth
Purpose:-textwidth returns the width of a string in pixels
Syntax:-textwidth(STRING);
Example:- i=textwidth(“HELLO”);
8.Getx
Purpose:-getx returns the current position of x o-ordinate
Syntax:-getx();
Example:- x=getx();
9.Gety
Purpose:-gety returns the current position of y co-ordinate
Syntax:-gety();
Example:- y=gety();
10.Getmaxx
Purpose:-getmaxx returns the maximum x co-ordinate on the screen
Syntax:-getmaxx();
Example:-maxx=getmaxx();
11.Getmaxy
Purpose:-getmaxy returns the maximum y co-ordinate on the screen
Syntax:-getmaxy();
Example:-maxy=getmaxy();
12.Line
Purpose:-Line function is used to draw the line on the screen.
Syntax: line(x1,y1,x2,y2);
Example:-line(100,100,200,100);
13.Closegraph
Purpose:-closegraph function shut down the graphic system
Syntax:- closegraph();
Example:- closegraph();
14.Moveto
Purpose:-moveto function moves current cursor position on the screen
Syntax:- moveto(x co-ordinate, y co-ordinate);
Example:- moveto(getmaxx/2, getmaxy/2);
15.Settextstyle
Purpose:-settextstyle sets the current text characteristics like font, direction and size
Syntax:-settextstyle(font, direction, size);
Example:-settextstyle(1,1,10);
16.Circle
Purpose: Circle function is used to draw the circle on the screen
Syntax:– circle(x,y,radius);
Example:circle(100,100,50);
17.Cleardevice
18.Outtextxy
Purpose: outtextxy function is used to print the text on the screen in graphics mode.
Syntax:outtext(x,y,text);
Example:-outtextxy(100,100,”HELLO”);
19.Sector
Purpose:sector function draws and fills an elliptical pie slice.
Syntax:sector(x, y, starting angle, ending angle, xradius, yradius);
Example:sector(100,100,45 135 100 50);
20.Arc
Purpose:arc draws the arc on the screen, arc is a part of the circle
Syntax:arc(x, y, starting angle, ending angle, radius);
Example:arc( 100,100,90,180,50);
21.Floodfill
Purpose:floodfill function is used to fill the color in the object, object may be circle, rectangle or any other closed image.
Syntax:floodfill(x,y,boundary color);
Example:floodfill(100,100,BLUE);
22.Ellipse
Purpose:ellipse function is used to draw the ellipse on the screen.
Syntax:ellipse(x, y, starting angle, ending angle, xradius, yradius);
Example:ellipse(100,100,90,200,20,20);
23.Outtext
Purpose:outtext function is used to display the text on the screen, using this function text is displayed in the current position.
Syntax:outtext(STRING);
Example:outtex(“HELLO”);
24.Getcolor
Purpose:getcolor returns the current drawing color.
Syntax:getcolor();
Example:intclr = getcolor();
25.Getpixel
Purpose:getpixel gets the color of a specified pixel.
Syntax:getpixel(x,y);
Example: color=getpixel(100,100);
26.Setfillstyle
Purpose: setfillstyle is used to set the color and style to be filled in the object using the flood fill method.
Syntax:setfillstyle(STYLE, COLOR);
Example:setfillstyle(1,RED)
1.Fully-immersive simulations:-
2.Semi-immersive simulations:-
3.Non-immersive simulations:-
2.Augmented Reality.:-