Lesson 53: File size calculator
このページには最新のブラウザ(SharedArrayBuffer対応)が必要です。Chrome、Edge、Firefox、Safariを最新バージョンに更新してください。
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.
難易度 3/5 · 200 コイン + 今日初回達成時の小ボーナス
Type the width, height and colour depth of an image, for example 512 512 16. readNumbers puts them in nums[0], nums[1] かつ nums[2]. Work out the file size: width × height × colour depth gives ビット; divide by 8 for バイト. The program prints the bytes and the size in KiB (bytes ÷ 1024).
実行ボタンをクリックして出力を確認してください。
難易度 3/5 · 200 コイン + 今日初回達成時の小ボーナス
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.
実行ボタンをクリックして出力を確認してください。