com.sun.jimi.core.encoder.sunraster
Class RLEOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--com.sun.jimi.core.encoder.sunraster.RLEOutputStream

public class RLEOutputStream
extends java.io.OutputStream

OutputStream wrapper for writing RAS-style RLE compressed data.


Field Summary
protected static byte FLAG_VALUE
          Value of the "Flag" indication an RLE run
protected  java.io.OutputStream out_
          Stream to write to.
protected  int runCount_
          Number of occurances of the value in the run.
protected  byte runValue_
          Value currently beingn used in a run.
 
Constructor Summary
RLEOutputStream(java.io.OutputStream out)
          Constructs an RLE-compressed wrapper for a given OutputStream.
 
Method Summary
protected  void compressBytes(byte[] data, int offset, int len)
          Compresses a byte array and writes it to the stream.
 void flush()
           
 void write(byte[] data)
          Compresses a byte array and writes it to the stream.
 void write(byte[] data, int offset, int length)
          Compresses a byte array and writes it to the stream.
 void write(int value)
          Compresses a byte into the stream.
protected  void writeLiteral(byte value)
           
protected  void writeRun()
           
protected  void writeRun(int run_count, byte run_value)
           
 
Methods inherited from class java.io.OutputStream
close
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FLAG_VALUE

protected static final byte FLAG_VALUE
Value of the "Flag" indication an RLE run

out_

protected java.io.OutputStream out_
Stream to write to.

runValue_

protected byte runValue_
Value currently beingn used in a run.

runCount_

protected int runCount_
Number of occurances of the value in the run.
Constructor Detail

RLEOutputStream

public RLEOutputStream(java.io.OutputStream out)
Constructs an RLE-compressed wrapper for a given OutputStream.
Parameters:
out - The underlying stream to write to.
Method Detail

compressBytes

protected void compressBytes(byte[] data,
                             int offset,
                             int len)
                      throws java.io.IOException
Compresses a byte array and writes it to the stream.
Parameters:
data - The data to compress.

write

public void write(byte[] data)
           throws java.io.IOException
Compresses a byte array and writes it to the stream.
Parameters:
data - The data to compress.
Overrides:
write in class java.io.OutputStream

write

public void write(byte[] data,
                  int offset,
                  int length)
           throws java.io.IOException
Compresses a byte array and writes it to the stream.
Parameters:
data - The data to compress.
offset - The offset in the data to start from.
length - The length of data to write.
Overrides:
write in class java.io.OutputStream

write

public void write(int value)
           throws java.io.IOException
Compresses a byte into the stream. This method is not optimal, use of the array-based write where possible is encouraged.
Parameters:
value - The data to compress.
Overrides:
write in class java.io.OutputStream

flush

public void flush()
           throws java.io.IOException
Overrides:
flush in class java.io.OutputStream

writeRun

protected void writeRun(int run_count,
                        byte run_value)
                 throws java.io.IOException

writeRun

protected void writeRun()
                 throws java.io.IOException

writeLiteral

protected void writeLiteral(byte value)
                     throws java.io.IOException