Class RleWriter
Inheritance
Namespace: PhotoshopFile
Syntax
public class RleWriter
Constructors
RleWriter(Stream)
Declaration
public RleWriter(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream |
Methods
Write(Byte[], Int32, Int32)
Encodes byte data using PackBits RLE compression.
Declaration
public int Write(byte[] data, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | data | Raw data to be encoded. |
System.Int32 | offset | Offset at which to begin transferring data. |
System.Int32 | count | Number of bytes of data to transfer. |
Returns
Type | Description |
---|---|
System.Int32 | Number of compressed bytes written to the stream. |
Remarks
There are multiple ways to encode two-byte runs:
- Apple PackBits only encodes three-byte runs as repeats.
- Adobe Photoshop encodes two-byte runs as repeats, unless preceded by literals.
- TIFF PackBits recommends that two-byte runs be encoded as repeats, unless preceded and followed by literals.
This class adopts the Photoshop behavior, as it has slightly better compression efficiency than Apple PackBits, and is easier to implement than TIFF PackBits.