You are on page 1of 5

Practical applications of BCD

The BIOS in many personal computers stores the date and time in BCD

Images
How data for a bitmapped image is encoded?

in
sa
us
H
A bitmap images take the form of an array, where the value of each element, called
q
a pixel picture element, correspond to the color of that portion of the image. Each
a

horizontal line in the image is called a scan line.


ht

The letter 'a' might be represented in a 12x14 matrix as depicted in above Figure the
us

values in the matrix depict the brightness of the pixels (picture elements). Larger values
-M

correspond to brighter areas whilst lower values are darker.

Binary Representation of Bitmap Images


M

All bitmap images are stored as an array of pixels. A monochrome bitmap will store a

1 for a black pixel and 0 for a white pixel (or vice-versa depending on the encoding

protocol).

Contact the teacher: 03215275281


This image could be represented by the following 35 binary digits (5 bytes):
00100 01010 01010 10001 11111 10001 00000
It would also be necessary to store the dimensions of the image.
If the image were in colour, using a colour palette of 256 possible shades, each pixel
would need to translate to a value between 0 and 256 (8 bits). Thus we would need 35
bytes to store the image.
It is common for colours to be recorded by quantity or Red, Green and Blue (RGB) and
this is stored using 3 bytes per pixel so we would need 105 bytes to store the image.
Bitmap images can be encoded in order to reduce the file size. Examples of encoded
bitmaps in clued JPG, PNG and GIF file types.

Bitmap file header


This block of bytes is at the start of the file and is used to identify the file. A typical
application reads this block first to ensure that the file is actually a BMP file and that it is

in
not damaged. The first two bytes of the BMP file format are the character 'B' then the

sa
character 'M' in 1-byte ASCII encoding

us
The size value occupies 4 bytes by default. However, with the use of the 4 reserved
bytes, this value can occupy 8 bytes (64 bits) while still conforming to the BMP file
H
header format.
q

Estimating file size of bitmapped image of different resolutions


a
ht

File size of a black white image


us

A black and white image has two dimensions that need to be considered the number of
pixels in the horizontal plane multiplied number of pixels along the vertical axis. Note
-M

that a black and white image is not grey scale.


M

Example

The formula is:

File size = horizontal pixels vertical pixels bit depth


-------------------------------------------
8(to convert to bytes) 1024 (kilobytes)

This image has the properties of 208 pixels wide by 182


pixels high. The file size in bits can then be worked out
by multiplying horizontal pixels by vertical pixels.

file size = 208 182 x 1

8 1024

= 37856
------
8192 = 4.62 KB

Contact the teacher: 03215275281


Bit depth adds a third dimension
Bit depth plays a roll once colour is included and it is important to keep in mind that
colour includes shades of grey. Because the bit depth is no longer a 1 or a zero it plays
an important part in the formula.

Number of Where do # of
Bit Depth
Colours Colours Come
(Bits Per Pixel)
or Tones From?

1 2 21=2

2 4 22=4

3 8 23=8

in
sa
4 16 24=16

6 64
us 26=64
H
8 256 28=256
a q

This grey scale image has 3 dimensions. Lets examine the properties of this image.
ht

Remember that because this image is a gif the actual file size will be different to the
us

result in the formula.


-M

The image is 200 pixels horizontal by 200 pixels vertical. Now we need to know the bit
depth. The bit depth of this image is 8.
M

File size = 200 200 8


-----------------
8 1024

= 320000
----------
8192

=39 KB

Contact the teacher: 03215275281


Activity 2

1. Find an uncompressed image. Right click on the thumbnail of the image and click on
properties. Now click the summary tab. You now can find all the details you need to work
out the file size of an image.

Calculating video size

The file size of an animation is simply a process of multiplying the number of frames by the
image size of each image.

in
sa
us
H
q

image courtesy of Bettscomputers.com


a
ht
us
-M
M

Contact the teacher: 03215275281


Calculating the total number of pixels in an image
Resolution is often given in dots per inch e.g. an image is 72 dots per inch. This means
that there are 72 dots in each inch running horizontally, and 72 dots in each inch
running vertically. Therefore in the image below which is of 1 inch x 1 inch, there would
be 72 x 72 = 5184 pixels

in
sa
us
H
q
FormulaNumber of pixels = image width x resolution x image height x resolution
a
ht

ExampleCalculate the number of pixels in 4 inch by 5 inch photograph scanned which


us

has a resolution of 600 dots per inch.Pixels = 4 x 600 x 5 x 600 = 7,200,000


-M

Calcluating colour depth


The colour depth is the number of bits used to represent the colour of a single pixel.
1 bit can be used to represent 2 colours
M

2 bits can be used to represent 4 colours


3 bits can be used to represent 8 colours
4 bits can be used to represent 16 colours

Formula
Number of colours = 2bit depth

Example
Calculate the number of colours which can be represented using 16 bits
Colours = 216 = 65536

Contact the teacher: 03215275281

You might also like