Show understanding of how data for both bitmap and vector graphics are encoded, be able to estimate file size, and justify the most suitable format for a given task.
Bitmap (raster) and vector graphics represent images in fundamentally different ways. A bitmap stores colour information for every pixel, while a vector stores a sequence of geometric drawing instructions. Both approaches have their own strengths, weaknesses, and typical file formats. The sections below describe the internal encoding of each type, how size is calculated, and how to choose the appropriate format for a particular application.
| Model | Typical depth per pixel | Encoding |
|---|---|---|
| RGB (24‑bit) | 8 bits per channel → 24 bits (3 bytes) | Three bytes per pixel: R G B |
| RGBA (32‑bit) | 8 bits per channel + 8 bits alpha → 32 bits (4 bytes) | Four bytes per pixel: R G B A |
| Indexed (8‑bit) | 8 bits per pixel → 1 byte | Pixel value is an index into a colour‑lookup table (palette). |
| CMYK (32‑bit) | 8 bits per channel → 32 bits (4 bytes) | Four bytes per pixel: C M Y K |
Compression reduces the number of stored bytes. The syllabus expects you to know the difference between lossless and lossy techniques and to recognise the most common algorithms.
Compression ratio is often expressed as uncompressed size ÷ compressed size. For example, a 2 MP 24‑bit image (≈6 MB) saved as JPEG with Q = 75 may be ~1 MB, giving a ratio of 6:1.
Because lossy compression discards data, further editing (e.g., colour correction) can degrade quality; lossless formats are preferred when the image will be edited repeatedly.
General formula:
File size = width × height × bytes‑per‑pixel + header + padding
Example – 800 × 600 pixels, 24‑bit RGB, no compression:
Pixels: 800 × 600 = 480 000
Bytes per pixel: 3
Raw data: 480 000 × 3 = 1 440 000 bytes ≈ 1.44 MiB
If each row must be a multiple of 4 bytes:
Row size = 800 × 3 = 2400 bytes → already divisible by 4 → no extra padding.
Total ≈ 1.44 MiB + header (≈54 bytes for BMP) ≈ 1.44 MiB
A vector image is a list of drawing instructions (primitives) together with attributes such as colour, stroke width, and transformation matrices. Because the description is mathematical, the image can be rendered at any size without loss of quality.
| Format | Typical use | Key characteristics |
|---|---|---|
| SVG (Scalable Vector Graphics) | Web icons, UI graphics | XML‑based, text readable, supports CSS styling, can embed raster images. |
| EPS (Encapsulated PostScript) | Print‑ready artwork, professional illustration | PostScript code, widely supported by printers, can contain both vector and bitmap objects. |
| PDF (Portable Document Format) | Documents, mixed raster‑vector layouts | Can embed vector graphics, raster images, fonts, and metadata; compression optional. |
| Command | Parameters | Purpose |
|---|---|---|
| M | x y | Move current point to \$(x,y)\$ (no drawing) |
| L | x y | Draw a straight line to \$(x,y)\$ |
| H | x | Horizontal line to \$x\$ (y unchanged) |
| V | y | Vertical line to \$y\$ (x unchanged) |
| C | x1 y1 x2 y2 x y | Cubic Bézier – two control points and an end point |
| Q | x1 y1 x y | Quadratic Bézier – one control point and an end point |
| Z | — | Close the current sub‑path (draw line back to start) |
M 100 100 L 200 100 L 150 200 Z
Explanation:
M 100 100 – move to \$(100,100)\$.L 200 100 – line to \$(200,100)\$.L 150 200 – line to \$(150,200)\$.Z – close the path (line back to the start point).Scale the triangle by a factor of 2 about the origin:
<g transform="matrix(2 0 0 2 0 0)"><path d="M 100 100 L 200 100 L 150 200 Z" />
</g>
The matrix(a b c d e f) stores six numbers (a b c d e f) that represent the 2‑D affine transformation. Only the six‑value matrix is stored; no new points are created, so file size is unchanged.
Four points: start \$P0\$, control \$P1\$, \$P2\$, end \$P3\$. The parametric equation is
\$\$
B(t) = (1-t)^3P0 + 3(1-t)^2tP1 + 3(1-t)t^2P2 + t^3P3,\qquad 0\le t\le1
\$\$
The C command supplies \$P1\$, \$P2\$ and \$P3\$; \$P0\$ is the current point.
#00FF00) or three separate bytes (R,G,B).Assume a simple SVG path consisting of:
M command (2 coordinates)L commands (2 coordinates each)Coordinates: (1 + 4) × 2 coords × 2 bytes = 20 bytes
Stroke colour: 3 bytes
Stroke width: 4 bytes
XML tags & whitespace (approx.): 30 bytes
Total ≈ 57 bytes
Increasing the number of commands, using 32‑bit floats for coordinates, or adding a transform matrix (24 bytes) will increase the size proportionally. This demonstrates why vectors remain compact for simple illustrations but can become large for highly detailed artwork.
<image> elements that reference external raster files or embed them as base‑64 data.When a raster element is present, the overall file size is the sum of the vector description plus the (compressed) bitmap size.
| Aspect | Bitmap | Vector |
|---|---|---|
| Data representation | Array of colour values for each pixel (plus header & metadata) | Sequence of drawing commands + attributes (XML or binary) |
| Scalability | Fixed resolution; scaling causes pixelation or blurring | Resolution‑independent; any size can be rendered perfectly |
| Typical file size | Grows with width × height × colour depth (e.g., 1 MP @ 24‑bit ≈ 3 MiB uncompressed) | Grows with number of primitives and attribute data; often < 10 KB for simple graphics |
| Best use case | Photographs, complex textures, raster effects | Logos, icons, schematics, technical drawings, UI elements |
| Compression options | Lossless (PNG, GIF, BMP + RLE) or lossy (JPEG, WebP) | Usually lossless; optional gzip/deflate compression for transmission (e.g., SVG + gzip) |
| Colour model support | RGB, indexed, CMYK, greyscale (format‑dependent) | RGB/RGBA (most common); colour‑profile metadata can be embedded |
| Editing impact | Lossy formats degrade with each edit; lossless formats preserve data but remain large. | Vectors can be edited indefinitely without quality loss; raster elements inside a vector inherit the raster’s edit limitations. |
Your generous donation helps us continue providing free Cambridge IGCSE & A-Level resources, past papers, syllabus notes, revision questions, and high-quality online tutoring to students across Kenya.