Show understanding of how data for a bitmapped image are encoded

Cambridge A‑Level Computer Science 9618 – 1.2 Multimedia & Core Foundations

Learning Objectives

  • Explain how data are represented in binary, hexadecimal, BCD and two’s‑complement forms.
  • Describe character encodings (ASCII, Unicode) and colour‑depth concepts.
  • Identify the main hardware components of a computer system and the role of different memory types.
  • Outline the Von Neumann architecture, the fetch‑decode‑execute cycle and the purpose of interrupts.
  • Analyse how bitmap and vector images are encoded, calculate their storage requirements and decide which representation is appropriate.
  • Understand basic sound sampling, calculate audio file sizes and recognise common audio formats.
  • Distinguish between lossless and lossy compression techniques and name the algorithms used in typical multimedia files.


1. Information Representation

1.1 Number Systems

  • Binary (base‑2) – digits 0, 1. Used internally by all digital devices.
  • Octal (base‑8) – digits 0‑7. Useful for grouping binary in 3‑bit blocks.
  • Decimal (base‑10) – digits 0‑9. Human‑friendly.
  • Hexadecimal (base‑16) – digits 0‑9, A‑F. Groups binary in 4‑bit nibbles; common in memory addresses.

Quick conversion table (8‑bit values)

BinaryHexDecimal
0000 0000000
0000 11110F15
0010 10102A42
1111 1111FF255

1.2 Binary‑Coded Decimal (BCD)

Each decimal digit is stored in a separate 4‑bit nibble. Example: 93₁₀ → 1001 0011₂ (9 = 1001, 3 = 0011). BCD simplifies decimal‑oriented I/O but wastes half the bits compared with pure binary.

1.3 Signed Numbers – Two’s‑Complement

  • Range for an n‑bit two’s‑complement integer: –2ⁿ⁻¹ … 2ⁿ⁻¹ – 1.
  • Negative value = invert all bits (one’s complement) then add 1.

Example (8‑bit)

+45 → 0010 1101

-45 → invert → 1101 0010, add 1 → 1101 0011 (binary) = –45

1.4 Character Encodings

  • ASCII – 7‑bit code (0‑127) covering English letters, digits and control characters.
  • Extended ASCII – 8‑bit, adds 128‑255 for additional symbols.
  • Unicode (UTF‑8/UTF‑16) – supports > 1 million characters; UTF‑8 is backward compatible with ASCII.

1.5 Colour Depth & Palette

  • Colour depth = bits per pixel (bpp). Determines the number of distinct colours: 2^(bpp).
  • Palette (indexed colour) stores a table of RGB triples; each pixel holds only an index into that table.

Common colour depths

bppColoursTypical use
12Black‑&‑white images
24Early video‑games
416Standard VGA
8256GIF, indexed PNG
1665 536High‑colour BMP
2416 777 216True‑colour photographs
3216 777 216 + alphaPNG‑32 with transparency


2. Computer Hardware Fundamentals

2.1 Core Components

  • CPU (Central Processing Unit) – executes instructions; contains ALU, registers, control unit.
  • Memory hierarchy

    • Registers – fastest, inside CPU, a few bytes each.
    • Cache – SRAM, speeds up access to frequently used data.
    • Main memory (RAM) – volatile; DRAM (dynamic) is common, SRAM is faster but more expensive.
    • Secondary storage – HDD, SSD, optical media; non‑volatile.

  • Input/Output (I/O) devices – keyboards, mouse, display, speakers, sensors, actuators.
  • Bus system – set of parallel wires that transfer data, addresses and control signals (e.g., system bus, address bus, data bus).

2.2 Memory Types

MemoryVolatile?Typical technologySpeed (relative)
RegisterYesSRAM inside CPUFastest
CacheYesSRAMVery fast
DRAM (main RAM)YesCapacitor‑based cellsFast
ROM (PROM/EPROM/EEPROM)NoMask/FlashSlow
SSD/HDDNoFlash/NmagneticSlowest

2.3 Embedded Systems (example)

Microcontroller + sensors + actuators → performs a dedicated task (e.g., temperature controller). Emphasise the limited memory and real‑time constraints.


3. Processor Fundamentals

3.1 Von Neumann Architecture

  • Single memory stores both data and program instructions.
  • CPU fetches an instruction, decodes it, executes it, then repeats – the Fetch‑Decode‑Execute (FDE) cycle.

Typical FDE cycle (register‑transfer notation)

FETCH: MAR ← PC ; address the next instruction

MBR ← MEM[MAR] ; fetch instruction

IR ← MBR

PC ← PC + 1

DECODE: Decode IR (determine opcode, operands)

EXECUTE: Perform operation (ALU, memory access, I/O)

3.2 Interrupts

  • Asynchronous signals that pause the current instruction stream.
  • CPU saves the current PC (and sometimes status registers) on a stack, jumps to an interrupt service routine (ISR), then restores state.
  • Types: hardware (external device), software (system call), timer‑based.

3.3 Example: Simple addition with an interrupt

; Assume accumulator A holds first operand

INT 0x10 ; hardware interrupt to read second operand into B

ADD B ; A ← A + B


4. Communication – Networking Fundamentals

4.1 Network Types & Topologies

NetworkTypical scaleTopology examples
LAN (Local Area Network)Building / campusStar, bus, ring
WAN (Wide Area Network)City / globeMesh, hybrid
PAN (Personal Area Network)Room / personStar (Bluetooth)

4.2 Client‑Server vs Peer‑to‑Peer

  • Client‑Server – centralised resources (e.g., web server). Scales well for many clients.
  • Peer‑to‑Peer – each node can act as client and server (e.g., file‑sharing).

4.3 IP Addressing

  • IPv4: 32‑bit dotted‑decimal (e.g., 192.168.1.25). Supports ~4.3 billion addresses.
  • IPv6: 128‑bit hexadecimal groups (e.g., 2001:0db8:85a3::8a2e:0370:7334).
  • Subnet mask determines network vs host portion; common masks: /24 (255.255.255.0), /16 (255.255.0.0).

Quick subnet example

Network: 192.168.10.0/24

Valid hosts: 192.168.10.1 – 192.168.10.254

Broadcast: 192.168.10.255

4.4 Core Protocols

  • TCP – connection‑oriented, reliable, ordered delivery.
  • UDP – connectionless, low‑latency, no guarantee of delivery.
  • HTTP / HTTPS – application‑layer protocol for web traffic.
  • DNS – translates domain names to IP addresses.
  • Ethernet / Wi‑Fi – physical and data‑link layer technologies; CSMA‑CD (wired) and CSMA‑CA (wireless) for media access.

4.5 Example Exam Question (AS)

Given the IPv4 address 172.16.5.130/20, determine the network address and the range of usable host addresses.

Solution

/20 → subnet mask 255.255.240.0

Network address: 172.16.0.0

First host: 172.16.0.1

Last host: 172.16.15.254

Broadcast: 172.16.15.255


5. Multimedia – Bitmap (Raster) Images – Encoding

5.1 Key Concepts

  • Pixel – smallest addressable element; identified by (x, y) coordinates.
  • Resolution – width × height in pixels.
  • Colour depth – bits per pixel (bpp).
  • Palette (colour table) – used in indexed‑colour images.
  • Bit planes – all bits occupying the same position across pixels; useful for image‑processing.

5.2 Colour‑Encoding Methods

Direct (True‑colour) Encoding

  • Each pixel stores its colour directly, usually as three separate channels R, G, B.
  • 24‑bit colour = 8 bits per channel → 16 777 216 possible colours.
  • 32‑bit colour adds an 8‑bit alpha channel for transparency.

Indexed (Palette‑based) Encoding

  • Pixel stores an index (1, 2, 4 or 8 bits) into a palette that holds the actual RGB triples.
  • Reduces file size when the image uses a limited set of colours.

5.3 Calculating Bitmap Data Size

Raw size (bits)

\[

\text{bits} = \text{width} \times \text{height} \times \text{bpp}

\]

Convert to bytes (divide by 8) and round up to the nearest whole byte. Many file formats pad each scanline to a 4‑byte boundary – add the padding when required.

Worked Example – 640 × 480, 8‑bpp indexed

  1. Total pixels = 640 × 480 = 307 200
  2. Bits = 307 200 × 8 = 2 457 600 bits
  3. Bytes = 2 457 600 ÷ 8 = 307 200 bytes ≈ 300 KB

5.4 Effect of Changing Resolution or Colour Depth

ResolutionbppFile size (KB)Typical visual quality
640 × 4808300Limited colour, suitable for simple graphics
640 × 48024900Rich colour, photographic detail
1280 × 72081 200More detail but still limited colour
1280 × 720242 764High‑definition colour image

5.5 Data Layout in Memory (row‑major order)

24‑bit RGB (no padding)

Byte 0: Red of pixel (0,0)

Byte 1: Green of pixel (0,0)

Byte 2: Blue of pixel (0,0)

Byte 3: Red of pixel (1,0)

...

8‑bit indexed (no padding)

Byte 0: Palette index of pixel (0,0)

Byte 1: Palette index of pixel (1,0)

...

5.6 Common File Formats & Their Encoding

  • BMP – uncompressed RGB or indexed data; optional RLE for 4/8‑bpp.
  • GIF – 8‑bpp indexed; uses LZW lossless compression.
  • PNG – supports 1‑32 bpp; uses DEFLATE (LZ77 + Huffman) lossless compression.
  • JPEG – 24‑bit true‑colour; lossy DCT‑based compression (outside raw bitmap encoding but essential for multimedia).


6. Multimedia – Vector Graphics – Encoding

6.1 What Is a Vector Graphic?

A vector image stores drawing instructions (geometric primitives) rather than colour for every pixel. The file contains coordinates, shapes and styling attributes, making the image resolution‑independent.

6.2 Core Elements

  • Objects – line, rectangle, circle, ellipse, polygon, Bézier path.
  • Properties – stroke colour, fill colour, line width, opacity, dash pattern.
  • Coordinate system – usually a Cartesian grid measured in user units (pixels, points, mm).

Simple SVG Example

<svg width="200" height="100">

<line x1="10" y1="10" x2="190" y2="10"

stroke="blue" stroke-width="2"/>

<circle cx="100" cy="60" r="40" fill="red"/>

</svg>

6.3 File‑Size Considerations

  • Size grows with the number of objects and the length of attribute strings, not with image dimensions.
  • Very complex drawings (thousands of paths) can become larger than a low‑resolution bitmap.

6.4 When to Use Vector vs. Bitmap

SituationPreferred formatReason
Logos, icons, UI elementsVector (SVG, EPS)Scalable, small file, easy colour changes
Photographs, texturesBitmap (JPEG, PNG)Colour detail cannot be expressed with simple shapes
Technical drawings with precise dimensionsVector (DXF, SVG)Exact geometry, easy editing
Pixel‑art or sprite sheetsBitmap (PNG, GIF)Pixel‑level control required


7. Sound – Basic Encoding

7.1 Fundamental Terms

  • Sampling rate (frequency) – samples per second (Hz). Common rates: 44.1 kHz (CD), 48 kHz (DVD), 22.05 kHz (telephone).
  • Bit depth – bits per sample; defines dynamic range (e.g., 16‑bit → 96 dB).
  • Channels – mono (1) or stereo (2); more channels increase size linearly.
  • Pulse‑Code Modulation (PCM) – raw, uncompressed audio representation.

7.2 Calculating Audio File Size (PCM)

\[

\text{bits} = \text{duration (s)} \times \text{sampling rate (samples/s)} \times \text{bit depth} \times \text{channels}

\]

Convert to bytes by dividing by 8.

Example – 10 s of CD‑quality audio

  1. Samples per channel = 44 100 × 10 = 441 000
  2. Total bits = 441 000 × 16 × 2 = 14 112 000 bits
  3. Bytes = 14 112 000 ÷ 8 = 1 764 000 bytes ≈ 1.68 MB

7.3 Common Audio Formats

  • WAV – stores raw PCM; large, no compression.
  • MP3 – lossy, psychoacoustic model; typical reduction to 1 %–10 % of original size.
  • AAC / OGG – modern lossy formats with better quality at similar bitrates.
  • FLAC – lossless compression; roughly 50 % size reduction while preserving original data.


8. Compression – Overview

8.1 Lossless vs. Lossy

  • Lossless – original data can be perfectly reconstructed (PNG, GIF, FLAC, ZIP). Ideal when any degradation is unacceptable.
  • Lossy – some information is permanently discarded to achieve higher compression (JPEG, MP3, AAC). Acceptable when a small loss in quality is tolerable for a large size reduction.

8.2 Typical Algorithms Used in Multimedia

AlgorithmTypeTypical mediaKey idea
RLE (Run‑Length Encoding)LosslessBMP (4/8‑bpp), simple graphicsReplace consecutive identical values with a count + value.
LZW (Lempel‑Ziv‑Welch)LosslessGIF, early PNGBuild a dictionary of repeated patterns.
DEFLATE (LZ77 + Huffman)LosslessPNG, ZIP, gzipSliding‑window duplication + variable‑length codes.
DCT‑based (Discrete Cosine Transform)LossyJPEG, MPEG‑1/2 videoTransform blocks to frequency domain, quantise, entropy‑code.
Psychoacoustic coding (e.g., MP3)LossyMP3, AACRemove audio components masked by louder sounds.

8.3 Example Exam Question (A‑Level)

Explain why a PNG image of a line drawing is usually smaller than a JPEG of the same picture, even though both have the same pixel dimensions.

Key points for answer

  • PNG uses lossless DEFLATE; JPEG uses lossy DCT which introduces artefacts.
  • Line drawings contain large uniform areas → RLE/DEFLATE compresses very well.
  • JPEG’s block‑based DCT is inefficient for sharp edges; it creates high‑frequency coefficients that increase size.


9. Choosing the Right Representation – Summary Table

CriteriaBitmap (Raster)Vector
Typical contentPhotographs, textures, complex colour gradientsLogos, icons, schematics, type‑set text
ScalabilityPixelation when enlargedResolution‑independent, crisp at any size
File‑size trendGrows with resolution × colour depthGrows with number of objects & attribute length
Editing focusPixel‑level colour editsShape manipulation, colour swaps
Typical formatsJPEG, PNG, GIF, BMPSVG, EPS, PDF, DXF


10. Exam‑Style Tips

  • Memorise the colour‑depth table and be able to convert bpp → number of colours.
  • Practice quick calculations of image and audio file sizes using the provided formulas.
  • Know the key differences between lossless and lossy compression; be ready to cite an example of each.
  • For networking, be comfortable converting between dotted‑decimal IPv4 and binary, and identifying network/host ranges.
  • When asked to choose a representation, reference at least two criteria (e.g., scalability and file size).