PackBits

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
m (Specifications)
 
Line 7: Line 7:
 
It is byte-oriented (as opposed to pixel-oriented), so depending on how the image data is organized, it may be ineffective for images that use more than one byte per pixel.
 
It is byte-oriented (as opposed to pixel-oriented), so depending on how the image data is organized, it may be ineffective for images that use more than one byte per pixel.
  
== Format ==
+
== Format details ==
 
The compressed data stream consists of a code byte, followed by zero or more data bytes, followed by another code byte, and so on.
 
The compressed data stream consists of a code byte, followed by zero or more data bytes, followed by another code byte, and so on.
  
Line 32: Line 32:
  
 
The reserved code byte (128 or −128) should be ignored, unless a format specification says otherwise. A few formats use it to mark the end of the compressed data.
 
The reserved code byte (128 or −128) should be ignored, unless a format specification says otherwise. A few formats use it to mark the end of the compressed data.
 +
 +
== Variants ==
 +
PackBits can easily be modified such that a unit of decompressed data is some fixed number of bytes greater than one. Formats that may use such variants include [[PICT]], [[Palm bitmap]], and [[IFF-DEEP]].
  
 
== Related formats ==
 
== Related formats ==

Latest revision as of 15:10, 9 May 2024

File Format
Name PackBits
Ontology

PackBits (or Apple Macintosh PackBits, or Macintosh RLE) is a form of run-length encoding often used to compress image data.

It is byte-oriented (as opposed to pixel-oriented), so depending on how the image data is organized, it may be ineffective for images that use more than one byte per pixel.

Contents

[edit] Format details

The compressed data stream consists of a code byte, followed by zero or more data bytes, followed by another code byte, and so on.

Code byte (N) Instructions
0 ≤ N ≤ 127 Interpret the next N+1 bytes literally.
N = 128 Reserved
129 ≤ N ≤ 255 Repeat the next byte 257−N times.

For whatever reason, PackBits is usually described in terms of signed bytes, which leads to the equivalent definition:

N = −128 Reserved
−127 ≤ N ≤ −1 Repeat the next byte 1−N times.
0 ≤ N ≤ 127 Interpret the next N+1 bytes literally.

The reserved code byte (128 or −128) should be ignored, unless a format specification says otherwise. A few formats use it to mark the end of the compressed data.

[edit] Variants

PackBits can easily be modified such that a unit of decompressed data is some fixed number of bytes greater than one. Formats that may use such variants include PICT, Palm bitmap, and IFF-DEEP.

[edit] Related formats

Formats that may use PackBits compression include MacPaint, PICT, TIFF, ILBM, and DEGAS.

[edit] Specifications

[edit] Resources

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox