Writing an RGB colour in binary

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Writing an RGB colour in binary

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. How is the RGB colour (255, 128, 0) written in binary?
A 11111111 10000000 00000000
B 11111111 1000000 0
2. How many bits are used for each colour channel (red, green or blue) in 24-bit colour?
A 8 bits (one byte)
B 24 bits
3. Which binary byte stores the red value 255?
A 10000000
B 11111111
4. The green value is 0. How is it stored in its byte?
A 0
B 00000000
5. How many bytes are joined together to make one pixel's colour in 24-bit RGB?
A 3 bytes
B 1 byte

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
111111111 10000000 00000000 AThe bytes are in the wrong order. 11111111 is in the red position, but the 255 belongs to green, so this is pure red.
200000000 00000000 11111111 BThe RGB colour (255, 128, 0) written as three 8-bit bytes: red, green and blue joined to make one pixel
3Each colour channel (red, green or blue) uses one byte, which is 8 bits C255 = 11111111
4Join the three bytes for red, green and blue in order to make one pixel D(255, 0, 128) = 11111111 00000000 10000000
5(255, 128, 0) = 11111111 1000000 0 EThe bytes are not each 8 bits. The 128 is only 7 bits (1000000) and the 0 has been left as a single digit.
6(0, 255, 0) = 11111111 00000000 00000000 FThe RGB colour (0, 0, 255), which is pure blue, written in binary

Definitions

11111111 10000000 00000000

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
Red 255 = 11111111 Green 128 = 10000000 Blue 0 = ________
2.
Each colour channel uses _ bits (one byte).
3.
Red + green + blue = _ bytes per pixel.
4.
(255, 128, 0) = 11111111 ________ 00000000
5.
(255, 0, 0) -> ________ 00000000 00000000

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A # One byte = 4 bits per channel
B red = 255 -> 11111111
C green = 128 -> 10000000
D blue = 0 -> 00000000
Question 2
A colour = (255, 128, 0)
B red = 255 -> 11111110
C green = 128 -> 10000000
D blue = 0 -> 00000000
Question 3
A colour = (0, 255, 0)
B red = 0 -> 0000
C green = 255 -> 11111111
D blue = 0 -> 00000000
Question 4
A colour = (64, 0, 255)
B red = 64 -> 10000000
C green = 0 -> 00000000
D blue = 255 -> 11111111
Question 5
A colour = (255, 192, 0)
B red = 255 -> 11111111
C green = 192 -> 01100000
D blue = 0 -> 00000000

Answer Key

Writing an RGB colour in binary
Section A: Quick Questions
Q1
A — 11111111 10000000 00000000
Q2
A — 8 bits (one byte)
Q3
B — 11111111
Q4
B — 00000000
Q5
A — 3 bytes
Section B: Match the Pairs
Q1
11111111 10000000 00000000 → The RGB colour (255, 128, 0) written as three 8-bit bytes: red, green and blue joined to make one pixel
Q2
00000000 00000000 11111111 → The RGB colour (0, 0, 255), which is pure blue, written in binary
Q3
Each colour channel (red, green or blue) uses one byte, which is 8 bits → 255 = 11111111
Q4
Join the three bytes for red, green and blue in order to make one pixel → (255, 0, 128) = 11111111 00000000 10000000
Q5
(255, 128, 0) = 11111111 1000000 0 → The bytes are not each 8 bits. The 128 is only 7 bits (1000000) and the 0 has been left as a single digit.
Q6
(0, 255, 0) = 11111111 00000000 00000000 → The bytes are in the wrong order. 11111111 is in the red position, but the 255 belongs to green, so this is pure red.
Section C: Definitions
Q1
11111111 10000000 00000000 — The RGB colour (255, 128, 0) written in binary. Each number becomes its own 8-bit byte for red, green and blue, and the three bytes are joined together to make one pixel.
Section D: Fill in the Blanks
Q1
Red 255 = 11111111 Green 128 = 10000000 Blue 0 = 00000000
Q2
Each colour channel uses 8 bits (one byte).
Q3
Red + green + blue = 3 bytes per pixel.
Q4
(255, 128, 0) = 11111111 10000000 00000000
Q5
(255, 0, 0) -> 11111111 00000000 00000000
Section E: Spot the Error
Q1
A — Each RGB channel is stored in one byte, and a byte is 8 bits, not 4. The comment should say 'One byte = 8 bits per channel'.
Q2
B — 255 in binary is 11111111 (all eight bits on). 11111110 is 254. The line should be red = 255 -> 11111111.
Q3
B — Every colour channel must be a full 8-bit byte, so 0 needs leading zeros: 00000000. Only 4 bits would break the 24-bit pixel.
Q4
B — 10000000 is 128, not 64. The 64 place value is the second bit from the left, so 64 is 01000000.
Q5
C — 192 = 128 + 64, so the two left-most bits are on: 11000000. 01100000 is 96.