To make a bitmap format smaller so that it can load faster and take up less disk space, you can compress its "picture" information. As a result, it "borrows a page" from the vector format by using a formula to define the image data.
Another way of thinking of compression it that it is a blueprint of the image. For example, a blueprint of a house is NOT the actual house. It is a set of instructions on how to build the house. The blueprint itself is a light weight set of instructions that represents how to actually build the house. Likewise, when you compress an image, you are writting the instruction on how to rebuild the actual image again. The same concept holds true for video.
There are two types of compression algorithm:
The gif and png formats support lossless compression. In lossless compression the image data is not lost or "throw out" only encoded. Hence, the image quality doesn't degrade as the amount of file compression increases.
In order to get the file size down smaller, it can be compressed using various compression algorithm. One type of compression is called Run Length Encoding (RLE).
As the name implies, Run Length Encoding will run the length of a line and encode each count of repeated data. For example, to encode the following line:
aabbbcccccdddddee
would be represented as: 2a3b5c5d2e which makes it easier to compress the data.
DEMO 1:
DEMO 2:
To DECODE the image, the formula is read back to draw (render) the image to the screen in the form of pixels.
The jpg format support lossy compression which does "throw out" image data. That's why it is not good to recompress a jpg image that has already been compressed. Image quality DOES degrade as the amount of file compression increases.
Beside compression, there are several ways to "throw out" information in an image to make is smaller: