大象传媒

Representing images

Images are made up of picture elements or pixels. These are tiny squares that appear on a screen. Each has a binary representation. The more pixels per inch on the screen, the higher the resolution of the picture. However, the higher the image , the more memory (number of bits) is needed to store the graphic.

You need a binary value for every unique colour in an image. If an image is black and white, then each pixel would be encoded as a 0 (for white) or a 1 (for black). The number of bits used for each pixel is called the .

In the example below, the space invader character has a colour depth of 2 bits, allowing us to encode 4 colours - 2 binary numbers, to the power of the number of bits (22 = 4). If the colour depth was eight bits, we could have a total of 256 colours (28 = 256).

A 2 bit image representing four colours

Bitmap

Digital cameras, smartphones and websites regularly use images.

A bitmap (map of bits) is a file format used to store digital images. Bitmap images are organised as a grid of coloured squares called pixels. Each different colour in the image is stored as a binary number.

When zooming in or enlarging a bitmap image, the pixels are stretched and made into larger blocks. The quality of bitmap images reduces as they are enlarged.

Graphic illustrating an image of a car enlarged 300%
Figure caption,
A bitmap image loses quality as it is scaled up

Vector

A image, rather than using blocks of colour to produce an image, uses mathematical calculations. Shapes such as straight lines and curves become scalable, without reducing quality.

As you zoom in or enlarge the shape, lines remain crisp. Vectors are not used for photographs, but line drawings or fonts.

Graphic of an image enlarged without being distorted
Figure caption,
A vector image retains its quality as it is scaled up

A vector is more efficient than a bitmap at storing large areas of the same colour because it does not need to store every pixel as a bitmap does. Because vector-based images are not made up of a specific number of pixels, they can be scaled to a larger or smaller size and not lose any image quality.

Vector graphics are used in , desktop publishing and the fonts on your computer.