CS09 : Painting by numbers

Ah, yes. A wildly pixelated Ben introduces us to the colourful world of bitmap images and bitmap encoding.

We are learning ...
  • How images are represented in computer systems
So that we can ...
  • Describe how images are represented as bitmaps
  • State the meanings of resolution, colour depth and image size
    - resolution can be expressed as pixel dimensions or pixel density
  • Calculate storage requirements for images
  • Discuss metadata that is commonly stored with images.

Activity 1 What is a 'bitmap? (20)

Images are very efficient ways of representing and communicating information. Human beings are very good at seeing patterns in visual displays. Images include, besides photographs and drawing or paintings, patterned displays of data, mathematical forms and graphs and charts. Images can be altered and manipulated, particularly if in digital form.


A digital images consists of a rectangular array or grid of "pixture elements", called pixels. Similarly, a television picture consists of an array of dots of different brightness and colour. A million or more pixels makes up a typical image. You can see individual pixels by looking at a computer screen with a magnifying glass.

How a TV Works in Slow Motion - The Slow Mo Guys (11:38)

Task 1.1 Inspect your screen
Eye glass (like jewelers use)

Using an eye glass, inspect the computer screen.  What do you see? Look at different parts of the screen.

OUTCOME : Description of a computer screen

A bitmap images is similarly made from individual pixels which are clearly visible if you zoom in on the image.

Task 1.2 Inspecting an image
Ainsley Harriott (BMP8).bmp

OK - here it is. You've all been waiting for it and your wait is over. There is an image of Ainsley Harriott in the resources for this lesson. Download, open it up with Windows Image Viewer (Right click and Preview) and zoom in as far as you can. Inspect the picture elements which Ainsley is made up from and enjoy.

OUTCOME : A close up view of Ainsley

No checkpoint to be honest

Activity 2 Pixel dimensions and resolution (30)

The term resolution can be, and often is, used incorrectly or inconsistently.

Resolution means ...
  • Pixel dimensions i.e. pixel width x pixel height
  • Pixel density i.e. the number of pixels per unit length
Pixel density is 'measured' in either ...
  • Pixels per inch (ppi) for displays
  • Dots per inch (dpi) for printers and scanner.

Task 2.1 Auction repair
Web browser

Visit the Auction repair website, read and make notes. The interesting / relevant bit is at the bottom of the page.

OUTCOME : Notes and possibly diagrams about resolution.

Activity 3 Colour depth (70)

Each pixel is stored as a number. A bitmap is characterised by the width and height of the image in pixels (the smallest unit on a screen or in memory) and the number of bits per pixel which determines the number of shades of grey or colours it can represent. A typical grey-scale image may have 256 alternative levels of brightness for each pixel and therefore must use one 8-bit byte per pixel to represent its value (28=256)

Task 3.1 How many colours?

How many colours can be represented using the following colour / bit depths?
  1. 1 bit per pixel?
  2. 2 bits per pixel?
  3. 3 bits per pixel?
  4. 4 bits per pixel?
  5. 8 bits per pixel?
  6. 16 bits per pixel?
  7. 24 bits per pixel?
  8. n bits per pixel?
OUTCOME : Answers to colour depth problems.

Whilst it's possible to represent colours in a bitmap using discrete binary codes for each colour, a bitmap representing a coloured image will usually have pixels with eight bits for each saturation level of the red, green, and blue components of the pixel (which is how screens work), though other colour encoding methods are also used.

Task 3.2 Draw your own bitmap image
Web browser
Pixie (portable colour picker software)
Bitmap canvas editor.xlsm

  • Use Pixie to investigate the colours of the pixels on your screen. There are 5 different encoding methods shown for describing the colour of each pixel - HEX, HTML, RGB, CMYK, HSV. Using suitable examples, explain how each method works.

  • Using the super groovy bitmap editor (it's a super spreadsheet cause I like spreadsheets) which is available in the resources for this lesson, try creating your own bitmap image by encoding the pixel colours by hand.  This is a 4 bit / 16 colour image.  Try experimenting and changing the colour palette from the one provided and see what you can come up with.  The 'ColourNames' tab will help you to choose the colours you want ...

OUTCOME : Written explanation of how the 5 colour systems work plus a masterpiece drawn pixel-by-pixel.

If you've managed to play around with the colour palette in the last activity, you should try a little more interactivity with another picture of your favourite chef.

Task 3.3 Psychedelic Ainsley
Ainsley Harriott (BMP8).bmp

Use Adobe Fireworks (or equivalent software) to experiment with altering my colour depth. Make sure you only use the BMP File format and experiment with the colour palette. Use the same image of Ainsley that you used in the previous exercise.

Try to make Ainsley look as psychedelic as possible. Try increasing or reducing the colour depth (number of colours) of the image. Make it spicy.

OUTCOME : Psychedelic image of Ainsley Harriott. 

Activity 4 Encoding and decoding images (50)

All bitmap images are encoded as a series of bits. Like any binary string, there is little you can do to interpret the string if you don't know something about the structure of the image.

Task 4.1 Encoding images
Bitmap encoding exercise.pptx

Encoding an image requires knowledge of the colour depth and dimensions required to represent the image. The pixel density (resolution) is not required unless you are printing the image. You are provided with a copy of three different images shown below. Your task is to encode them as bitmaps. For each one, you have to decide firstly on the colour depth required and therefore how many bits per pixel you will need to represent that number of colours. How will you decide which colour to use for each pixel?

If each image is to be printed at 4 pixels per inch (an extremely low resolution), what physical size will each image print out at?

OUTCOME : Encoded bitmap of each image together, with colour palette if required.

If you look carefully at the results from the last activity, you'll see that it's impossible to tell where one row ends and another one begins unless you know both ...
  • the colour depth (i.e. how many bits per pixel there are);
  • the pixel dimensions (there is no guarantee that it will be square).
Also, it's impossible to recreate the image unless you have the colour palette available - how do you know what colour 01001000 represents if you don't have the palette, eh?

Task 4.2 Decoding images
Graph paper.pdf
Coloured pencils / pens

  • The following bitmap represents a square, 2 colour image. Construct the image in a suitable grid.


  • The following bitmap represents a 5x7 pixel image with 4 colours. The colour palette is ...

    00 = Black
    01 = Yellow
    10 = Green
    11 = White


 : Nice bitmap images with colours if relevant.

Activity 5 Calculating file size (20)

Number of pixels = 800 x 600 = 480,000
Bits per pixel = 4 (which allows 16 colours)
Total number of bits = 480,000 x 4 = 1,920,000
Total number of bytes = 1,920,000 / 8 = 240,000 B or 234.375 kB or 0.22889 MB

The most appropriate file size for this image is 234.375 kB as it lies between 1 and 1024. Choose this way, OK?

Task 5.1 Some for you to try!

Calculate the file size of the following images. Express your answers in the most appropriate file size unit. Write your answers in your books showing your working.
  • 1024 x 768 / 4 colours
  • 1366 x 768 / 256 colours
  • 1920 x 1020 / 16,777,216 colours

OUTCOME : Clear file size calculations in your books; with the correct answers.

Activity 6 Steganography (40)

Steganography is the name given to a (fairly) ancient art involving hiding secret messages inside other seemingly plain and non-suspicious text or images.

Task 6.1 Hiding a secret message in a dogs nose.
OpenStego (portable software)
Dogs nose.jpg
Secret message.txt

There are lots of steganography programs out there. OpenStego is free and portable so suits our needs.

  • Investigate how it works and practice sending secret messages to each other.  For added security, you can encrypt the secret message first before you send it.
  • What is the limit of the size of file you can hide inside an image?  Can you 'see' the effects of the hidden file?
OUTCOME : Description of steganography in your notebooks including examples.

Activity 7 File formats (65)

There are only a few common bitmap (or raster) file formats which are commonly in use. You might recognise ...

JPEG - Joint Photographics Expert Group
TIFF - Tagged Image File Format
GIF - Graphics Interchange Format
BMP - BitMaP
PNG - Portable Network Graphic

Task 7.1 Same image, different format.
Ainsley Harriott (BMP8).bmp

Using the image of good old Ainsley, investigate the different file formats that you can export him in. If there are any settings available in each format, experiment with them.

OUTCOME : Discussion on filetypes and compression options for file image export. 

The file formats of images do not just contain the bitmap data, they also contain metadata - data about data. The metadata contained in an image file varies depending on how the image was created and what device it was created on.

Task 7.2 Metadata
Ainsley Harriott.xyz
Downpatrick Head.jpg

  • With each picture you have made of Ainsley, upload each one to Jeffrey's Exif Viewer (Exchangeable Image File Format) website or, if that's not available, Metapicz, and inspect the 'metadata' which is stored with each one. You will find that some versions of the picture contain different data which describes it.

  • You'll find another really nice picture called Downpatrick Head.jpg in the resources for the lesson as well. It's from my Summer holiday in Ireland - nice. Upload this to Jeffrey's Exif Viewer or, if that's not available, Metapicz, website and be amazed at how much data it contains apart from the picture. Quite handy if you ever forget where or when you took the photo!

OUTCOME : A list of the common and interesting metadata which is stored in images in your notebook.

Extension Activities 

How about these ...
  • Investigate web-safe colour palette at http://cloford.com/resources/colours/websafe1.htm

  • Investigate colour schemes at http://paletton.com

  • Install and use GIMP to produce a simple bitmap image. Print your image out and stick it into your assessment book. Write about what you have done and how you made the image. You should save the image and use a suitable resource to inspect the metadata contained in it. Write about the metadata you have found.

  • Use an online crossword creator to produce a crossword for the keywords in this topic.
What's next?

Before you hand your book in for checking, make sure you have completed all the work required and that your book is tidy and organised. Your book will be checked to make sure it is complete and you will be given a spicy grade for effort.