A lossless file compressor and decompressor written in C using Run-Length Encoding (RLE).
The program can compress and decompress any binary file, making it suitable for text files, images, executables, and other binary data.
- Compresses arbitrary binary files
- Decompresses files back to their original form
- Uses a simple Run-Length Encoding (RLE) algorithm
- Implemented in pure C
- Lightweight and easy to understand
.
├── main.c
├── README.md
└── bin
└── Debug
└── Compressor.exe
The project was created using Code::Blocks.
Alternatively, it can be compiled with GCC:
gcc main.c -o CompressorCompressor compress input_file output_fileExample:
Compressor compress image.bmp image.rleCompressor decompress input_file output_fileExample:
Compressor decompress image.rle restored.bmpThe compressor uses Run-Length Encoding (RLE).
Instead of storing repeated bytes individually, it stores:
(byte value, repetition count)
For example:
Input:
AAAAABBBBCC
is stored as:
(A,5)(B,4)(C,2)
Each repetition count is stored in a single byte, allowing runs of up to 255 consecutive bytes.