Documentation ¶
Overview ¶
Package lzw implements the Lempel-Ziv-Welch compressed data format. This is the format described in T. A. Welch, “A Technique for High-Performance Data Compression”, Computer, 17(6) (June 1984), pp 8-19.
In particular, the package implements LZW as used by the PDF file format, which means variable-width codes up to 12 bits and the first two non-literal codes are a clear code and an EOF code. Both the correct and the "early change" variant are implemented.
The main differences to the compress/lzw package are:
- the pdf/lzw package sends a clear code as the first code (required for Preview on MacOS)
- pdf/lzw optionally implements the "early change" variant
- pdf/lzw always uses MSB bit order and 8-bit literals
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is an io.Reader which can be used to read compressed data in the LZW format.
func NewReader ¶
NewReader creates a new io.ReadCloser. Reads from the returned io.ReadCloser read and decompress data from src. If src does not also implement io.ByteReader, the decompressor may read more data than necessary from src. It is the caller's responsibility to call [Close] on the ReadCloser when finished reading.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is an LZW compressor. It writes the compressed form of the data to an underlying writer (see NewWriter).
func NewWriter ¶
NewWriter creates a new io.WriteCloser. Writes to the returned io.WriteCloser are compressed and written to dst. It is the caller's responsibility to call Close on the WriteCloser when finished writing.