Share on Facebook Share on Twitter Email
Answers.com

PackBits

 
Wikipedia: PackBits

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. This compression scheme is one of the types of compression that can be used in TIFF-files; TGA files also use a scheme similar to PackBits for RLE compression, but treat the data stream as pixels instead of bytes and use a different counting method.

A PackBits data stream consists of packets with a one-byte header followed by data. The header is a signed byte; the data can be signed, unsigned, or packed (such as MacPaint pixels).

In the following table, n is the value of the header byte as a signed integer.

Header byte Data following the header byte
0 to 127 (1 + n) literal bytes of data
-1 to -127 One byte of data, repeated (1 – n) times in the decompressed output
-128 No operation (skip and treat next byte as a header byte)

The TGA variant is as follows, where n is the value of the header as an unsigned integer.

Header Data
0 to 127 (1 + n) pixel values
128 to 255 1 pixel repeated (n – 127) times

Runs of two bytes adjacent to non-runs are typically written as literal data. It should also be noted that there is no way based on the PackBits data to determine the end of the data stream; that is to say, one must already know the size of the compressed or uncompressed data before reading a PackBits data stream to know where it ends.

External links


Search unanswered questions...
Enter a question here...
Search: All sources Community Q&A Reference topics
 
 
Learn More
Run-length encoding
Truevision TGA
Indexed color

Post a question - any question - to the WikiAnswers community:

 

Copyrights:

Wikipedia. This article is licensed under the Creative Commons Attribution/Share-Alike License. It uses material from the Wikipedia article "PackBits" Read more