Converting Binary & Images
Computer Science: OCR GCSE, topic 1.2.27
Converting Binary and Images
All images are stored as binary. It's important to be able to convert between an image and its binary representation.

Binary to image
- In a black and white image, each pixel is represented by 1 bit:
- A 0 will represent a black area.
- A 1 will represent a white area.
- The image will be represented by a binary string. Use the value of each bit to colour each pixel in the right colour.
- The binary string starts at the top-left of the image, and represents the first row, followed by the second row, and continues until the end of the image.

Image to binary
- Each pixel of the image will be represented by one bit of the binary string.
- Starting at the top left, and working across the first row:
- Write a 0 if the pixel is black.
- Write a 1 if the pixel is white.
- Continue this process until the end of the image.
Test yourself on Converting Binary & Images
A black and white image uses how many bits per pixel?