packbits

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2021 License: MIT Imports: 1 Imported by: 0

README

PackBits Compression in Go

Overview

This package provides an implementation of the PackBits compression scheme for Go. The PackBits compression scheme is a simple lossless run-length encoding scheme. It originally appeared as the compression scheme used by MacPaint on Macintosh computers in 1984.

References

Example of Usage

// Compress raw data.
data := []byte{
    0xAA, 0xAA, 0xAA, 0x80, 0x00, 0x2A, 0xAA, 0xAA,
    0xAA, 0xAA, 0x80, 0x00, 0x2A, 0x22, 0xAA, 0xAA,
    0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
}
packed := packbits.Pack(data)

// Decompress packed data.
unpacked, err := packbits.Unpack(packed)

Efficiency

There is more than one way to encode a given block of raw data. I believe that this library will always choose one of the smallest possible encodings. In certain circumstances, this means merging adjancent blocks of data into a single block.

License

PackBits is distributed under the terms of the terms of the MIT license. See LICENSE.txt for details.

Documentation

Overview

Package packbits implements the PackBits lossless data compression scheme, as used on old Macintosh computers.

See Apple Technical Note TN1023.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidData = errors.New("invalid PackBits data")

ErrInvalidData indicates that the PackBits data is invalid and cannot be decompressed.

Functions

func AppendPack added in v1.1.0

func AppendPack(out, data []byte) []byte

AppendPack compresses the data using the PackBits compression scheme, appending the compressed data to the given slice.

func Pack

func Pack(data []byte) []byte

Pack compresses the data using the PackBits compression scheme.

func Unpack

func Unpack(data []byte) ([]byte, error)

Unpack decompresses the data using the PackBits compression scheme.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL