Lesson 53: File size calculator
Trang này cần trình duyệt gần đây (hỗ trợ SharedArrayBuffer). Vui lòng cập nhật Chrome, Edge, Firefox hoặc Safari lên phiên bản mới nhất.
English
How big is the file?
- A file size sum always has the same steps: work out the bits, then change the unit.
- 8 bits = 1 byte. 1024 bytes = 1 kibibyte (KiB). 1024 KiB = 1 mebibyte (MiB).
- Let the Arduino do the sum, then check it by hand.
Words for this lesson
| Word | Meaning |
|---|---|
| resolution (image) | width × height in pixels |
| colour depth | bits for each pixel |
| sample rate | sound samples each second (Hz) |
| sample resolution | bits for each sample |
English
The two formulas
| File | Bits |
|---|---|
| image | width × height × colour depth |
| sound | sample rate × resolution × seconds |
- Bytes = bits ÷ 8. KiB = bytes ÷ 1024.
English
In the exam
- 0478/12/M/J/24 Q1(d): a 16-bit colour image, 512 × 512 pixels. File size in KiB? Mark scheme: 512 KiB.
- 0478/12/O/N/24 Q2(c): a 10 second sound, sample rate 22 016 Hz, resolution 8 bits. File size in KiB? Mark scheme: 215 KiB.
- 0478/12/F/M/23 Q4(b): an image of 1000 × 1000 pixels with a colour depth of 2 bytes. Mark scheme: 2 000 000 bytes. Careful: here the colour depth is already in bytes, so do not divide by 8.
- Always show your working: each step can get a mark.
Độ khó 3/5 · 200 xu + phần thưởng nhỏ khi hoàn thành lần đầu tiên hôm nay
Type the width, height and colour depth of an image, for example 512 512 16. readNumbers puts them in nums[0], nums[1] và nums[2]. Work out the file size: width × height × colour depth gives bit; divide by 8 for bytes. The program prints the bytes and the size in KiB (bytes ÷ 1024).
Nhấn Chạy để xem kết quả ở đây.
Độ khó 3/5 · 200 xu + phần thưởng nhỏ khi hoàn thành lần đầu tiên hôm nay
Now a sound file. Type the sample rate (Hz), the sample resolution (bits) and the length (seconds), for example 22016 8 10. Sample rate × resolution × seconds gives bits; divide by 8 for bytes.
Nhấn Chạy để xem kết quả ở đây.