← 返回资讯屏轩教育 · 行业资讯

Data Storage and File Compression | 数据存储与文件压缩

2026-08-03 04:47 · 本文部分内容由AI辅助创作

📚 Data Storage and File Compression | 数据存储与文件压缩

In today's digital world, every image you share, every sound you stream, and every document you type is stored and transmitted as data. Understanding how data is measured, represented, and compressed is essential for managing storage space and improving transfer speeds. This article explores the key concepts of data storage units, binary representation, file size calculations, and the principles of lossless and lossy compression, all aligned with the Cambridge IGCSE syllabus.

在当今的数字世界中,你分享的每一张图片、流媒体传输的每段声音,以及输入的每份文档,都以数据的形式存储和传输。理解如何测量、表示和压缩数据,对于管理存储空间和提高传输速度至关重要。本文探讨数据存储单位、二进制表示、文件大小计算以及无损与有损压缩的原理,完全紧扣剑桥 IGCSE 课程大纲。


1. Units of Data Storage | 数据存储单位

All data in a computer is stored as binary digits (bits). A single bit can be either 0 or 1. Eight bits form a byte, which is the basic unit for measuring file sizes. Multiples of bytes follow powers of 2, although storage manufacturers sometimes use decimal multiples. The most common units are kilobyte (kB), megabyte (MB), gigabyte (GB), and terabyte (TB).

计算机中的所有数据都以二进制数字(比特/位)存储。单个比特可以是 0 或 1。八个比特组成一个字节,这是衡量文件大小的基本单位。字节的倍数遵循 2 的幂次,尽管存储制造商有时采用十进制倍数。最常见的单位是千字节 (kB)、兆字节 (MB)、吉字节 (GB) 和太字节 (TB)。

When calculating file sizes, always use the binary definitions (powers of 1024) unless the question states otherwise. The difference between binary and decimal measurement can cause confusion in marketed storage capacity.

在计算文件大小时,除非题目另有说明,始终使用二进制定义(1024 的幂次)。二进制与十进制度量的差异可能会导致标示存储容量时的混淆。


2. Binary Representation of Data | 数据的二进制表示

Computers represent text, images, and sound as sequences of binary numbers. Text is commonly encoded using ASCII (7 or 8 bits per character) or Unicode (up to 32 bits). Each character maps to a unique binary code. For example, the uppercase 'A' is 01000001 in ASCII.

计算机将文本、图像和声音表示为二进制数字序列。文本通常使用 ASCII(每个字符 7 或 8 比特)或 Unicode(高达 32 比特)编码。每个字符对应一个独一无二的二进制代码。例如,大写字母 'A' 在 ASCII 中为 01000001。

Images are represented as a grid of pixels, where each pixel is assigned a binary value for its colour. The colour depth (bit depth) determines how many bits are used per pixel. A 1‑bit image can only show black and white, while an 8‑bit image can display 256 colours (28), and a 24‑bit true‑colour image can represent over 16 million colours (224).

图像表示为像素网格,每个像素被赋予一个二进制颜色值。颜色深度(位深度)决定每个像素使用多少比特。1 位图像只能显示黑白两色,8 位图像可显示 256 种颜色 (28),而 24 位真彩色图像可呈现超过 1600 万种色彩 (224)。

Sound is captured by sampling the analogue signal at regular intervals and converting each sample into a binary number. The sample rate (e.g., 44.1 kHz) and sample resolution (e.g., 16 bits) affect the quality and size of the digital audio.

声音通过定期对模拟信号进行采样并将每个样本转换为二进制数字来捕获。采样率(如 44.1 kHz)和采样精度(如 16 比特)影响数字音频的质量和大小。


3. Calculating File Sizes for Text | 文本文件大小计算

The size of a plain text file depends on the number of characters and the bit length of each character. If ASCII is used with one byte per character, a document containing 2000 characters would be 2000 bytes in size (approximately 1.95 kB).

纯文本文件的大小取决于字符数和每个字符的比特长度。如果使用每个字符一字节的 ASCII 编码,一份包含 2000 个字符的文档的大小为 2000 字节(约 1.95 kB)。

file size in bytes is 3000 × 1 = 3000 bytes. Convert to kilobytes: 3000 / 1024 ≈ 2.93 kB.

示例:一个文本文件包含 3000 个以扩展 ASCII(每个字符 8 比特)表示的字符。文件大小为 3000 × 1 = 3000 字节。转换为千字节:3000 / 1024 ≈ 2.93 kB。

When Unicode (UTF‑16) uses 2 bytes per character, the same 3000 characters would require 6000 bytes, about 5.86 kB. As character encoding expands, file size grows proportionally.

当 Unicode (UTF‑16) 每个字符使用 2 字节时,同样的 3000 个字符需要 6000 字节,约 5.86 kB。随着字符编码的扩展,文件大小会成比例增长。


4. Calculating File Sizes for Images | 图像文件大小计算

(width in pixels × height in pixels) by the colour depth (bits per pixel). The formula is:

File size (bits) = width (pixels) × height (pixels) × colour depth (bits)

未压缩图像的文件大小可以通过将图像分辨率(宽像素 × 高像素)乘以颜色深度(每像素比特数)来估算。公式为:

文件大小 (比特) = 宽度 (像素) × 高度 (像素) × 颜色深度 (比特)

For example, an image with dimensions 800 × 600 pixels and a 24‑ e 800 × 600 × 24 = 11,520,000 bits. Divide by 8 to get bytes: 1,440,000 bytes (≈ 1.37 MB).

例如,一幅尺寸为 800 × 600 像素、颜色深度为 24 比特的图像需要 800 × 600 × 24 = 11,520,000 比特。除以 8 得到字节数:1,440,000 字节(约 1.37 MB)。

0,000 bytes (≈ 0.46 MB). This demonstrates how colour depth directly influences file size.

如果颜色深度降至 8 比特(256 色),大小变为 800 × 600 × 8 = 3,840,000 比特,即 480,000 字节(约 0.46 MB)。这展示了颜色深度如何直接影响文件大小。


5. Calculating File Sizes for Sound | 声音文件大小计算

Uncompressed audio file size is determined by the sample rate, sample resolution, number of channels, and duration. The calculation is:

size (bits) = sample rate (Hz) × sample resolution (bits) × channels × duration (seconds)

未压缩音频文件大小由采样率、采样精度、声道数和时长决定。计算公式为:

文件大小 (比特) = 采样率 (Hz) × 采样精度 (比特) × 声道数 × 时长 (秒)

A 30‑second CD‑quality stereo track (sample rate 44,100 Hz, 16‑ × 30 = 42,336,000 bits. Converted to megabytes: 42,336,000 / (8 × 1024 × 1024) ≈ 5.05 MB.

一段 30 秒 CD 音质的立体声轨道(采样率 44,100 Hz,16 位精度,2 声道)将产生:44,100 × 16 × 2 × 30 = 42,336,000 比特。换算为兆字节:42,336,000 / (8 × 1024 × 1024) ≈ 5.05 MB。

Reducing the sample rate or resolution significantly lowers the file size but also sacrifices audio fidelity. Understanding these relationships helps when choosing quality settings for digital media.

降低采样率或精度会大幅减小文件大小,但也会牺牲音频保真度。理解这些关系有助于在为数字媒体选择质量设置时做出判断。


6. The Need for File Compression | 文件压缩的必要性

Uncompressed media files can be extremely large, consuming excessive storage space and saturating network bandwidth. Compression reduces the number of bits needed to represent data, making storage more efficient and transmission faster. There are two main motivations: to save storage on devices, and to reduce download/upload times over the internet.

未压缩的媒体文件可能极其庞大,占用过多的存储空间并消耗网络带宽。压缩减少了表示数据所需的比特数,使存储更高效、传输更快速。这背后有两个主要动机:节省设备上的存储空间,以及缩短互联网上的下载/上传时间。

Without compression, uploading a high‑resolution raw photograph could take minutes, and streaming high‑fidelity music would require impractical bandwidth. Compression enables practical digital ecosystems, from social media to video conferencing.

没有压缩,上传一张高分辨率的原始照片可能需要数分钟,流媒体传输高保真音乐则需要不切实际的带宽。压缩使得从社交媒体到视频会议等实用的数字生态系统成为可能。


7. Lossless Compression | 无损压缩

Lossless compression reduces file size without discarding any data. The original file can be perfectly reconstructed from the compressed version. This is essential for text documents, spreadsheets, and any application where exact reproduction is critical.

无损压缩在减小文件大小的同时不丢弃任何数据。原始文件可以从压缩版本中完美重建。这对于文本文档、电子表格以及任何要求精确再现的应用至关重要。

Run‑length encoding (RLE) is a simple lossless method. It replaces consecutive repeated data with a count and the value. For example, the string "AAAAABBB" becomes "5A3B". This works well for simple graphics with large uniform areas. More advanced lossless algorithms like DEFLATE (used in ZIP files) combine dictionary encoding and Huffman coding to compress a wide variety of data.

游程编码 (RLE) 是一种简单的无损方法。它用计数和值来替换连续重复的数据。例如,字符串 "AAAAABBB" 变成了 "5A3B"。这种方法对于有大面积均匀区域的简单图形效果良好。更高级的无损算法如 DEFLATE(用于 ZIP 文件)结合了字典编码和霍夫曼编码,可压缩各种不同类型的数据。

Common lossless formats include PNG for images, FLAC for audio, and ZIP for general files. The compression ratio is often modest, but no quality is lost.

常见的无损格式包括用于图像的 PNG、用于音频的 FLAC,以及用于通用文件的 ZIP。压缩比率通常较为温和,但质量不会损失。


广告 / Sponsored

8. Lossy Compression | 有损压缩

Lossy compression achieves much higher compression ratios by permanently discarding some data, particularly information that human senses are less likely to notice. This method is ideal for photographs, music, and videos where a small loss of quality is acceptable in exchange for dramatic size reduction.

有损压缩通过永久丢弃部分数据,尤其是人类感官不太容易察觉的信息,来实现高得多的压缩比。这种方法非常适用于照片、音乐和视频,在这些场景中用少许质量损失换取大幅体积缩减是可以接受的。

JPEG is a classic lossy format for images. It exploits the limitations of human vision by reducing colour detail and grouping pixels into blocks. MP3 audio compression removes frequencies that are masked by louder sounds, significantly shrinking file sizes while preserving perceived quality. Modern codecs like AAC and H.264 also apply lossy techniques.

JPEG 是一种典型的有损图像格式。它利用人眼的局限性,减少色彩细节并将像素分组为块。MP3 音频压缩则移除被更大声音遮蔽的频率,在保持听觉质量的同时大幅缩小文件尺寸。AAC 和 H.264 等现代编解码器同样运用有损技术。

Once data is removed through lossy compression, it cannot be recovered. Repeated editing and re‑saving of lossy files can cause generation loss, progressively degrading quality.

一旦数据通过有损压缩被移除,便无法恢复。对有损文件反复编辑和重新保存会造成代际损失,逐渐降低质量。


9. Comparing Lossless and Lossy Compression | 无损与有损压缩对比

The table below summarises the key differences between lossless and lossy compression, helping you choose the appropriate method for different scenarios.

下表总结了无损与有损压缩的关键差异,助你根据不同场景选择合适的方法。

Aspect Lossless Lossy
Data recovery Perfect reconstruction Some data permanently lost
Compression ratio Moderate (typically 2:1 to 5:1) High (often 10:1 to 100:1)
Typical file types PNG, FLAC, ZIP, GIF JPEG, MP3, MP4, GIF (limited)
Quality after compression Identical to original Reduced, but often imperceptible
Best used for Text, code, archival Photos, music, streaming
方面 无损 有损
数据恢复 完美重建 部分数据永久丢失
压缩比 中等(通常 2:1 至 5:1) 高(通常 10:1 至 100:1)
典型文件类型 PNG, FLAC, ZIP, GIF JPEG, MP3, MP4, GIF (有限)
压缩后质量 与原件完全相同 降低,但通常难以察觉
最佳用途 文本、代码、归档 照片、音乐、流媒体

In practice, many applications use a combination of both. For example, a ZIP file may use lossless compression, while the images inside remain in lossy JPEG format.

在实践中,许多应用程序会结合使用两者。例如,ZIP 文件可能采用无损压缩,而其中的图像仍保持有损的 JPEG 格式。


10. Compression Ratio and Trade‑offs | 压缩比与权衡

The compression ratio is a measure of how much a file has been reduced in size. It is calculated by dividing the uncompressed size by the compressed size. A higher ratio indicates better compression. For example, if a 10 MB file compresses to 2 MB, the ratio is 5:1.

压缩比是衡量文件体积缩减程度的指标。它由未压缩大小除以压缩后大小计算得出。比率越高,表示压缩效果越好。例如,如果 10 MB 的文件压缩至 2 MB,压缩比即为 5:1。

d) / original) × 100. In the example above, the space saving is ((10 − 2) / 10) × 100 = 80%. Choosing a compression method involves trade‑offs between file size, quality, and processing time.

空间节省也可表示为百分比:((原始 − 压缩) / 原始) × 100。在上述示例中,空间节省为 ((10 − 2) / 10) × 100 = 80%。选择压缩方法涉及在文件大小、质量以及处理时间之间的权衡。

Lossless compression is mandatory when every bit matters, such as in software distribution or medical imaging. Lossy compression is acceptable for entertainment media where perceptual quality is the primary concern.

当每一个比特都关系重大时,无损压缩是必须的,例如在软件分发或医学成像中。而对于以感知质量为主要考量的娱乐媒体,有损压缩则可以被接受。


11. Common File Formats and Their Compression | 常见文件格式及其压缩方式

Different file formats employ specific compression strategies tailored to the type of data they store. Understanding these formats aids in making informed decisions about storage and quality.

不同的文件格式采用针对其所存储数据类型量身定制的压缩策略。了解这些格式有助于在存储和质量方面做出明智的决定。

Knowing when to save a diagram as PNG rather than JPEG, or when to archive files as ZIP, reflects a solid grasp of compression principles and is frequently tested in IGCSE examinations.

知道何时将图表保存为 PNG 而非 JPEG,或何时将文件归档为 ZIP,反映对压缩原理的牢固掌握,也是 IGCSE 考试中常见的考查点。


12. Real‑World Applications and Exam Tips | 实际应用与备考提示

Compression is everywhere: streaming services like Netflix use lossy codecs to deliver video efficiently; cloud storage providers compress data to maximise capacity; operating systems create compressed archives to save space. Even web pages are transmitted in compressed form (gzip) to reduce loading times.

压缩无处不在:像 Netflix 这样的流媒体服务使用有损编解码器高效传输视频;云存储提供商压缩数据以最大化容量;操作系统创建压缩归档以节省空间。甚至网页在传输时也采用压缩形式 (gzip) 来缩短加载时间。

In the IGCSE exam, you may be asked to calculate file sizes before and after compression, identify whether a scenario requires lossless or lossy compression, or explain how a particular compression method works. Always show your working clearly, state the formula, and convert units correctly. Remember to use 1024 for binary conversions unless the question specifies 1000.

在 IGCSE 考试中,你可能会被要求计算压缩前后的文件大小,判断某个场景需要无损还是有损压缩,或解释特定压缩方法的工作原理。务必要清晰展示计算步骤,写出公式,并正确转换单位。除非题目指定使用 1000,否则记住用 1024 进行二进制换算。

Practice with sample data: calculate the size of a 5‑minute mono recording at 8 kHz, 8‑bit, and compare it with an MP3 version compressed to 128 kbps. These exercises build the numeracy and reasoning skills expected by the examiners.

用示例数据进行练习:计算一段 5 分钟单声道录音在 8 kHz、8 比特时的大小,并与压缩至 128 kbps 的 MP3 版本进行比较。这些练习能培养考官所期望的运算和推理能力。

Published by TutorHao | Science Revision Series | aleveler.com

广告 / Sponsored
现货 Cambridge International AS & ALevel IT Coursebook剑桥国际IGC…
计算机 备考教辅 · 正版现货 · 与本文内容相关
查看详情 / View on Taobao参考价 ¥467.0

更多咨询请联系16621398022(同微信)

备考资讯每日更新,关注不错过
考纲变化 · 科目分析 · 学习方法
扫码关注公众号 tutorhao
在微信里长按二维码识别关注
或截图后用「扫一扫 → 相册」选择本图
公众号:tutorhao