Upload
jelani-holloway
View
17
Download
3
Embed Size (px)
DESCRIPTION
In this chapter, you will learn. How computer handles graphic objects The differences between a bitmap file and a vector file The differences among different common graphic file formats. Handling Computer Graphics. Computer Handles data in binary format: 0 or 1 (bit). 2 8 = 256. - PowerPoint PPT Presentation
Citation preview
By Netbalone - www.netbalone.com
Com
pu
ter
Gra
ph
ics
In this chapter, you will learnIn this chapter, you will learn
– How computer handles graphic objects
– The differences between a bitmap file and a vector file
– The differences among different common graphic file formats
By Netbalone - www.netbalone.com
Com
pu
ter
Gra
ph
ics
Number of Bits No. of states1 28
162432
Handling Computer Handling Computer GraphicsGraphics
– Computer Handles data in binary format: 0 or 1 (bit)
28 = 256216 = 65,535
224 = 16,777,216232 = 4,294,967,296
By Netbalone - www.netbalone.com
Com
pu
ter
Gra
ph
ics
Bitmap Graphics
• A bitmap graphic is represented by a dot pattern
• Each dot is called a Pixel (picture element)• A pixel has a single color only
Pixel
By Netbalone - www.netbalone.com
Com
pu
ter
Gra
ph
ics
To have a better understanding of bitmap graphics, let’s start with the simplest type of bitmap picture - Monochrome (i.e. B&W) Bitmap
By Netbalone - www.netbalone.com
Com
pu
ter
Gra
ph
ics
• A pixel can be Black or white (2 states)• So, 1 bit can be used to code the color
B&W Bitmap Graphics
111111111111111111111111110001111111111101111111111111000111111111111000111111111111011111111111110000111111111111001111111111111011111111111101111111111111
1 - White0 - Black
1 - White0 - Black
By Netbalone - www.netbalone.com
Com
pu
ter
Gra
ph
ics
B&W Bitmap Graphics
• Therefore, a full screen (800 x 600) monochrome bitmap picture requires storage of
(800 x 600 x 1) bits= 480000 bits= 60000 bytes= 58.59 kB
By Netbalone - www.netbalone.com
Com
pu
ter
Gra
ph
ics
Grayscale Bitmap Graphics
• Grayscale graphics are created by using shades of gray• 8 levels of grayscale
000 001 010 011 100 101 110 111
How many bits should be used to How many bits should be used to represent the gray colors of each represent the gray colors of each pixel?pixel?
3 bits3 bits
By Netbalone - www.netbalone.com
Com
pu
ter
Gra
ph
ics 256 colors Bitmap Graphics
How many bits are necessary to represent 256 colors in each pixel?
8 bits8 bits
By Netbalone - www.netbalone.com
Com
pu
ter
Gra
ph
ics
• How many bits are necessary to represent a 800 x 600 graphic of 256 colors?
Question:Question:
Number of bits used= 800 x 600 x 8 bits= 3,840,000 bits
(Storage required: 468.75 kB)
The larger the resolution and the no. of colors, the more storage spaces are required to hold the graphic
The larger the resolution and the no. of colors, the more storage spaces are required to hold the graphic
By Netbalone - www.netbalone.com
Com
pu
ter
Gra
ph
ics
Vector Graphics
• A vector graphic is divided into objects
• Each object is defined by the method of drawing it
This picture contains 3 objects:a line, a circle and a rectangle
This picture contains 3 objects:a line, a circle and a rectangle
By Netbalone - www.netbalone.com
Com
pu
ter
Gra
ph
ics
How to draw the circle?
• The circle is represented by a mathematical formula:
Circle(50,100,150,black,1,green)Circle(50,100,150,black,1,green)
Radius
Center
Line colorLine thickness
Fill color
A few bits is enough to save the properties of this circle!A few bits is enough to save the properties of this circle!
By Netbalone - www.netbalone.com
Com
pu
ter
Gra
ph
ics Advantages of using Vector
Graphics:• It requires less storage space• When a vector graphic is enlarged, it remains intact (no
distortion)
Enlarging a Vector Graphic
Enlarging a Bitmap Graphic
The line is as smooth as before
The line thickened & saw-tooth resulted
By Netbalone - www.netbalone.com
Com
pu
ter
Gra
ph
ics
Common Graphic File Format
Bitmap (.bmp) - a common graphic file format;can be read by almost all programs
Gif (.gif) - a compressed bitmap file format. It can support up to 256 colors
Jpeg (.jpg) - a lossy compressed bitmap file format. But it can support up to 16.7 million colors
(because it applies lossy compression, some of the details is lost!)
By Netbalone - www.netbalone.com
Com
pu
ter
Gra
ph
ics
Comparison Table:
Fileformat
File Size Maximum numberof colours support
Quality of image Remarks
Bmp Large(uncompressed bitmap)
256 Good seldom used due to itslarge file size.
Gif Small(compressed bitmap)
256 Good commonly used
Jpg smallest (Lossycompression)
16.7 million varied, best fortrue colour photo
File size and quality offile can be controlled,Used in most digital
cameraVector Small Depends on
different softwareCompatible to a
few software onlyProprietary format
By Netbalone - www.netbalone.com
Com
pu
ter
Gra
ph
ics
8-bit color means 28 = 256 different colors
16-bit (High) color means 216 = 65535 different colors
24-bit (True) color means 224 = 16777216 different colors
How colors are represented?
The number of bits used to represent colors is called color depth.The number of bits used to represent colors is called color depth.
By Netbalone - www.netbalone.com
Com
pu
ter
Gra
ph
ics
RGB Color Scheme
• All colors are made up of 3 primary colors of light: Red (R), Green (G) and Blue (B)
• Different intensities of red, green and blue can mix up different colors
• In computer, 8 bits are used to represent 256 levels of each of these primary colors
Com
pu
ter
Gra
ph
ics
By Netbalone - www.netbalone.com
Example:
• RGB(255,0,0) = Red
• RGB(0,255,0) = Green
• RGB(0,0,255) =
• RGB(0,0,0) =
• RGB(255,255,255) =
• RGB(255,0,255) =
Http://www.phy.ntnu.edu.tw/~hwang/image/rgbColor.html
Blue
Black
White
Magenta