Sunteți pe pagina 1din 34

# Chapter 5.

3 Bitmapped
and Vector Graphics
Computing department

KEYWORDS
Pixel
Bitmap
Resolution
Colour depth
Bytes-Kilobytes-Megabytes
Vector graphics
Data compression
The Topic for Presentation ......
• The meaning of bitmap
• The meaning of resolution
• The meaning of colour depth
• How to calculate the size of a bitmap in
bytes, kilobytes and megabytes
• The meaning of vector graphic
bitmapped and vector graphics
• The meaning of data compression
• Basic image compression techniques
• Summary
5.3.1 Bitmapped Graphics
In bitmapped graphics, an image is divided into
a grid of picture elements called pixels (a pixel
is the smallest addressable area or smallest
solid block of colour in an image).
The colour in each grid cell is sampled and
then assigned a binary code to represent the
average colour in that cell which is then stored
in a particular position in memory. A bitmap is
created when the pixels of an image are
mapped to positions in memory that store
binary codes representing the colour of each
pixel.
5.3.1 Bitmapped Graphics
A Bitmapped Graphic is a mapping of pixels in
an image to positions in memory that store
binary codes representing the colour of each
pixel.
In bitmapped graphics, a image is divided into a
grid of picture elements called pixels. Picture 2
shows how Picture 1 may look when turned into
pixels.
Picture 1 Picture 2
5.3.2 Resolution of a VDU Screen
A pixel is the smallest addressable area or
smallest solid block of colour in an image.

## The resolution of a visual display unit (VDU)

is expressed as the number of pixels per row
by the number of pixels per column. Some
typical resolutions are1024x798, 800x600,
640x480.

## A VDU screen resolution setting of 1024x798

(817,152 pixels) contains more pixels than a
screen resolution of 640x480 (371,200 pixels).
5.3.2 Resolution of an Image
It is not the number of pixels that determines
the sharpness of an image but the size of each
pixel. The smaller the better. A small image size
containing a large number of pixels should
produce the sharpest image.

## Therefore a better definition of resolution is the

number of dots/pixels per inch or centimetre.

## The resolution of an image is a quantity

expressed as the number of dots or pixels per
inch or centimetre.
5.3.3 Colour Depth
The number of bits used to represent the
colour or greyscale value of a single pixel in
a bitmapped image is called the colour
depth. The colour of a single pixel can be
coded using the RGB colour model, which
mixes Red, Green and Blue additively to
produce a specific colour. In this model the
relative brightness of red, blue and green
are encoded separately. To produce white,
the values for R, G and B are all set to
100%. To produce black, the values are all
set to 0%.
5.3.3 Colour Depth – contd.
Types of colour depth:-
1-bit colour
A black and white image is known as a
monochrome image. 1 bit is allocated to
each pixel, restricting the colour to black or
white. 0 = Black, 1 = White.
12-bit colour
In 12-bit direct colour, 4 bits are allocated for
each of the R,G and B components,
enabling 4,096 (16 x 16 x 16) different
colours. Used in some mobile phones.
5.3.3 Colour Depth – contd.
Types of colour depth:-
True colour
True colour can mimic many colours found in
the real world, producing 16.7 million
distinct colours. This approaches the level
at which the human eye can distinguish
colours for most photographs. 24-bit true
colour uses 8 bits for red, 8 for blue and 8
for green, giving 2^8 (256) levels of each of
the three primary colour components. They
can therefore be combined to five a total of
16,777,216 (256 x 256 x 256) colours.
5.3.3 Colour Depth – contd.
Types of colour depth:-
32-bit colour
32-bit is really true colour with and extra 8 bits
chosen because the word size of modern
PCs is 32 bits or 64 bits. The extra 8 bits
are either ignored or used to represent the
alpha channel, which is a way of providing
partial transparency.

## [Recap of Colour Depth: the number of bits

used to represent the colour of a single
pixel in a bitmapped image.]
5.3.4 Memory Requirements
Suppose a bitmapped image of size 8 pixels x
8 pixels uses 8 bits (or 1 byte) to encode the
colour of each pixel. The image has a size of
8 x 8 pixels (64 pixels in total). Therefore, a
minimum of 64 bytes is required to store the
image’s bitmap.
If 16 bits are used per pixel, then a minimum of
128 bytes are needed for the bitmap.
Using 32 bits per pixel requires 256 bytes.
5.3.4 Memory Requirements
If we use a higher resolution for the image,
keeping its dimensions the same, we need
to create a bitmap of more pixels.
For example, if we double the size in pixels in
each dimension from 8 x 8 to 16 x 16, we
increase the number of pixels by a factor of
4, so our minimum memory requirements
must also increase by a factor of 4.
Using 32 bits per pixel requires 32 x 32 = 1024
bytes.
5.3.5 Bitmap file calculations
Increasing the resolution of a bitmapped VDU
screen increases the amount of memory
required to display graphics, as does
increasing the colour depth.
E.g. a screen set to a resolution of 1024x768
and a colour depth of 32 bits needs a
memory of 1024x768x4 bytes = 3,145,728
bytes = 3 MB.
Therefore at least 3 MB is required to save the
displayed graphic in a file.
5.3.6 Vector Graphics
Instead of dividing a graphic into pixels, a
vector graphic identifies the objects
that make up the image – the lines,
arcs, curves, circles, ellipses,
rectangles, polygons, etc. Even text is
broken down into straight lines and
curves.
these objects to create the image.
Pixels are in no way used in this
process.
5.3.6 Vector Graphics
5.3.6 Vector Graphics
For example, a line 100 pixels long needs
just a few bytes to describe it in vector
graphics whereas 100 x 3 bytes are
required in a bitmap using 24-bit colour.
Vector drawing software uses the
commands that create objects as the
source of information needed to
describe the graphic.
5.3.6 Vector Graphics
Key Terms
Vector Graphic: records geometric and
other information about the objects that
make up an image.
Object: a component of a vector graphic,
such as a line, a rectangle or a circle.
5.3.7 Drawing List
Key Term
Drawing List: the list of drawing
commands that recreate a vector
graphic.
Object information (in vector graphic
format) is recorded in a file. This format
lists all the objects making up the
graphic with necessary information
about each object as a list of drawing
commands – the drawing list. These
drawing commands can be used to
recreate the graphic.
5.3.8 Properties of Objects
To recreate a vector graphic, the properties of
every object in the drawing list must be
specified. Properties or attributes of a
vector graphic object are position, size,
direction (possibly using endpoint
coordinates), line thickness, font size and
description of the curves, whether a closed
shape is filled or not, the fill colour, whether
the closed shape has a border, the colour
and thickness of any border.
5.3.9 Pros and Cons of Bitmapped
and Vector Graphics
1. Geometric images require fewer bytes in
vector graphic format than in bitmap format.
2. Images that have continuous areas of
colour, such as photographic images, take
up fewer bytes in bitmaps than vector
graphics.
3. Geometric images load faster from
secondary storage (magnetic disk) and
graphic format.
5.3.9 Pros and Cons of Bitmapped
and Vector Graphics –Contd.
4. Vector graphic images scale without
distortion whereas bitmapped images do
not – bitmapped image suffer from
pixelation when enlarged (= the staircase
effect).
5. Some vector graphic formats can be
searched for particular graphic objects
which may then be manipulated; it is much
harder to do this with bitmapped images.
5.3.9 Pros and Cons of Bitmapped
and Vector Graphics –Contd.
5.3.10 Data Compression
The purpose of data compression is to squeeze
data into a smaller number of bytes therefore
decreasing the file size. Bitmapped graphic
files can be very large, but it is possible to
reduce the size of these by various
compression techniques.

## Types of Data Compression:-

1. Run-length encoding
2. Lossy compression
5.3.10 Data Compression
1. Run-length encoding (RLE)
RLE is a lossless compression technique which
takes into account that some images have long
runs of pixels that are the same colour. If three
or more consecutive cells are found to have
the same colour then that run of cells can be
encoded in two bytes. The first byte stores the
number of identical consecutive (contiguous)
memory cell bytes and the second byte stores
the colour code. Decompressing an RLE-
compressed image produces the original
uncompressed image exactly without loss.
Examples: GIF, JPEG and PNG.
5.3.10 Data Compression
2. Lossy compression
Lossy compression discards information which is
not considered important e.g. background
scenery is saved with reduced resolution.
Decompressing results in an uncompressed
image that is different from the original

## (NB: Read the Case Study on page 122 in Bond

which describes the main differences between
the different image formats)
Chapter 5.3 Summary
 A pixel is the smallest addressable area or
solid block of colour in a image
 A bitmap is created when the pixels of an
image are mapped to binary codes for their
colours
 Image resolution is the number of
dots/pixels per inch or centimetre
 Screen resolution is the number of pixels in
the horizontal dimension by the number of
pixels in the vertical dimension
Chapter 5.3 Summary
 Colour depth is the number of bits used to
represent the colour of a single pixel in a
bitmapped image
 The size of a bitmap in bytes is its size in
pixels multiplied by its colour depth in bytes
 A vector graphic records information about
the objects that make up an image
 A vector graphic object is a graphic
component such as a line, a rectangle or a
circle
Chapter 5.3 Summary
 A drawing list is the list of drawing
commands that create the vector graphic
 Properties of a graphic object describe its
size, direction, thickness, shading, font size,
typeface, etc
 Data compression squeezes uncompressed
data into fewer bytes
 Run-length encoding is a lossless method
of image compression
 Lossy image compression reduces
resolution of parts of the picture eg the
background
Chapter 5.3 Summary
 Scaled bitmapped graphics become
distorted whereas scaled vector graphics do
not distort
 Geometric images take up less memory
and load faster when saved as vector
graphics
 Photographs with lots of continuous colour
take up less memory when saved as
bitmapped graphics
Chapter 5.3 Questions
1. What is a pixel?
2. What is a bitmap?
3. What is meant by the resolution of an
image?
4. What is meant by colour depth?
5. Calculate the minimum file size of a
bitmapped image of size 1024 x 768 pixels
that uses a colour depth of 24 bits.
Chapter 5.3 Questions
6. What are vector graphics?
7. Why does an image of geometric diagrams
stored as a vector graphic require fewer
bytes than when stored as a bitmap?
8. What is meant by a drawing list in vector
graphics?
9. Name six properties of a vector graphic?
10. Compare the scaling of a bitmapped
graphic with a vector graphic.
Exam Questions
TAKE A LOOK AT THE FOLLOWING
QUESTIONS:

CPT1 JAN 06 – Q9 B
CPT1 JAN 08 – Q5
CPT1 JAN 09 – Q6
CPT1 JUN 08 – Q6
COMP1 JUN 09 – Q1