Reading history

Data Representation: Text, Images and Sound

5 min read 0 views

Learn how computers store text with ASCII and Unicode, images with pixels and colour depth, and sound with sampling, plus file size calculations and compression.

A computer stores only 0s and 1s. Yet it shows Bangla text, family photos and your favourite song. How? Each kind of data has an agreed code that turns it into bits and back again. In this lesson you will learn how text, pictures and sound are stored, why some files are huge and others tiny, and how to work out file sizes yourself.

In this lesson you will learn

  • How characters are stored with ASCII and Unicode
  • Why Bangla text needs Unicode
  • How bitmap images use pixels and colour depth
  • How sound is sampled and stored
  • How to calculate file sizes, and what compression does

You should know binary numbers and bits, bytes and storage units.

Text: ASCII

To store text, every character gets a number, and the number is stored in binary. The first widely used code was ASCII (American Standard Code for Information Interchange). It uses 7 bits, so it has 2⁷ = 128 codes. These cover English letters, digits, punctuation and some control codes such as “new line”.

Character   Decimal   Binary
'A'           65      1000001
'B'           66      1000010
'a'           97      1100001
'0'           48      0110000
space         32      0100000

"Hi" is stored as 72 105  →  1001000 1101001

Notice that capital and small letters differ by exactly 32. Notice too that the character ‘0’ is code 48, not 0. The digit you see on screen is just a symbol with its own code.

Text: Unicode

128 codes are far too few for the world’s languages. Unicode gives a unique number, called a code point, to over 150,000 characters from almost every writing system, plus symbols and emoji. Bangla letters sit in the block from U+0980 to U+09FF. For example, the letter ক is U+0995.

Unicode code points are usually stored using UTF-8. It uses 1 byte for English letters (the same as ASCII), and 2 to 4 bytes for other characters. Each Bangla letter takes 3 bytes in UTF-8.

Why this matters in Bangladesh

Older Bangla fonts used their own private codes. Text typed in one of them looked like nonsense on a computer without that exact font. Unicode Bangla, typed with keyboards such as Avro or the national standard layout, shows correctly on any modern phone, computer or website, and can be searched.

Images: Pixels and Colour Depth

A bitmap image is a grid of tiny squares called pixels. Each pixel stores a colour as a binary number.

000110000011110001111110111111110001100000011000000110008 × 7 pixels, 1 bit eachstored bits1 = black pixel0 = white pixelSize: 8 × 7 × 1= 56 bits = 7 bytesWith 24-bit colour eachpixel needs 24 bits instead
  • Resolution is the number of pixels, written width × height, such as 1920 × 1080.
  • Colour depth is the number of bits per pixel. 1 bit gives 2 colours (black and white). 8 bits give 256 colours. 24 bits give over 16 million colours: 8 bits each for red, green and blue.
File size (bits) = width × height × colour depth

A 1920 × 1080 photo at 24 bits per pixel:
1920 × 1080 × 24 = 49,766,400 bits
÷ 8 = 6,220,800 bytes ≈ 6.2 MB (before compression)

More pixels or more colours give a better picture, but a bigger file. Vector images work differently. They store shapes as instructions, such as “draw a circle here, this size”. Logos and icons are often vectors because they stay sharp at any size.

Sound: Sampling

Sound is a smooth wave. To store it, the computer measures the wave’s height many times a second. Each measurement is a sample.

  • Sample rate: how many samples per second, in hertz (Hz). Music CDs use 44,100 Hz.
  • Bit depth: how many bits store each sample. CDs use 16 bits, which allows 65,536 different levels.
  • Channels: 1 for mono, 2 for stereo.
File size (bits) = sample rate × bit depth × channels × seconds

One minute of CD-quality stereo:
44,100 × 16 × 2 × 60 = 84,672,000 bits
÷ 8 = 10,584,000 bytes ≈ 10.6 MB

A higher sample rate and bit depth make the recording closer to the real sound, but the file grows.

Compression

Compression makes files smaller so they take less space and download faster.

LosslessLossy
IdeaFinds patterns and stores them more brieflyThrows away detail people hardly notice
Get the original back?Yes, exactlyNo, only something close
ExamplesZIP, PNG, FLACJPEG, MP3, MP4 video
Best forText, program files, spreadsheetsPhotos, music, video

A simple lossless trick is run-length encoding. A row of pixels such as WWWWWWBBBW can be stored as 6W 3B 1W, which is shorter when there are long runs of the same colour.

Common Mistakes

  1. Forgetting to divide by 8. The formulas give bits; divide by 8 to get bytes.
  2. Thinking the digit ‘5’ is stored as 101. As text it is stored as its character code, 53.
  3. Using lossy compression for documents. Losing data from a text or program file would break it.
  4. Thinking more pixels always look better. A small, blurry photo will not get sharper just by being enlarged.

Practice Exercises

Exercise 1. The ASCII code for ‘C’ is 67. What is the code for ‘c’?

Show answer

Small letters are 32 higher, so 67 + 32 = 99.

Exercise 2. Find the size in bytes of a 100 × 50 pixel image with 8-bit colour.

Show answer

100 × 50 × 8 = 40,000 bits. 40,000 ÷ 8 = 5,000 bytes.

Exercise 3. A 10-second mono recording uses 8,000 samples per second and 8 bits per sample. How many bytes is it?

Show answer

8,000 × 8 × 1 × 10 = 640,000 bits = 80,000 bytes, which is 80 KB.

Frequently Asked Questions

What is the difference between ASCII and Unicode?

ASCII is an old 7-bit code with 128 characters, mainly English. Unicode gives a number to well over a hundred thousand characters from almost all languages, including Bangla. The first 128 Unicode characters are the same as ASCII.

What is the difference between lossy and lossless compression?

Lossless compression shrinks a file so it can be rebuilt exactly, as in ZIP and PNG. Lossy compression removes detail that people barely notice, as in JPEG and MP3, so the original cannot be fully restored.

Summary

  • Text is stored as character codes: ASCII for basic English, Unicode (often in UTF-8) for every language.
  • Bitmap size = width × height × colour depth, in bits.
  • Sound size = sample rate × bit depth × channels × seconds, in bits.
  • Lossless compression keeps every bit; lossy compression drops some detail to save more space.

Next: Data Communication and Transmission Media.

Lessons are also marked complete when you click Next.

Leave a Reply

Your email address will not be published. Required fields are marked *