PackBits is a fast, simple lossless compression scheme for run-length encoding of data.
Apple introduced the PackBits format with the release of MacPaint on the Macintosh computer.
TGA files also use this RLE compression scheme, but treats data stream as pixels instead of bytes.
Runs of two bytes adjacent to non-runs are typically written as literal data.
The following code, written in Microsoft VBA, unpacks the data: The same implementation in JavaScript: