rebuild.graphics.tiff
Class Writer

java.lang.Object
  extended by rebuild.graphics.tiff.Writer

public final class Writer
extends java.lang.Object

A data type writer for TIFF.

Since:
BBX 1.0.1

Field Summary
static short ASCII
          8-bit byte that contains a 7-bit ASCII code; the last byte must be NUL (binary zero), the last byte is taken care of by the Writer.
static short BYTE
          8-bit unsigned integer.
static short DOUBLE
          Double precision (8-byte) IEEE format.
static short FLOAT
          Single precision (4-byte) IEEE format.
static short LONG
          32-bit (4-byte) unsigned integer.
static short LONG8
          A 64-bit (8-byte) unsigned integer.
static short RATIONAL
          Two LONGs: the first represents the numerator of a fraction; the second, the denominator.
static short SBYTE
          An 8-bit signed (twos-complement) integer.
static short SHORT
          16-bit (2-byte) unsigned integer.
static short SLONG
          A 32-bit (4-byte) signed (twos-complement) integer.
static short SLONG8
          A 64-bit (8-byte) signed (twos-complement) integer.
static short SRATIONAL
          Two SLONG’s: the first represents the numerator of a fraction, the second the denominator.
static short SSHORT
          A 16-bit (2-byte) signed (twos-complement) integer.
static short UNDEFINED
          An 8-bit byte that may contain anything, depending on the definition of the field.
 
Constructor Summary
Writer(boolean littleEndian, java.io.OutputStream out)
          Create a new Writer.
 
Method Summary
 boolean getLittleEndian()
          Get if the encoder is in little-endian format.
static long shiftValue(byte value, int pos)
          Shift a value so it is in a format that the Writer can write out.
static long shiftValue(int value, int pos)
          Shift a value so it is in a format that the Writer can write out.
static long shiftValue(short value, int pos)
          Shift a value so it is in a format that the Writer can write out.
static byte unshiftByte(long value, int pos)
          Unshift a value so it is in a format that is useable.
static int unshiftInt(long value, int pos)
          Unshift a value so it is in a format that is useable.
static short unshiftShort(long value, int pos)
          Unshift a value so it is in a format that is useable.
 void write(byte[] data)
          Write an array of bytes to the stream.
 void write(byte[] data, int off, int len)
          Write an array of bytes to the stream.
 void writeASCII(char value)
          Write a 7-bit ASCII code.
 void writeASCII(java.lang.String value)
          Write a ASCII string.
 void writeASCII(java.lang.String[] values)
          Write an array of ASCII strings.
 void writeByte(int value)
          Write a BYTE or SBYTE.
 void writeDouble(double value)
          Write a DOUBLE.
 void writeFloat(float value)
          Write a FLOAT.
 void writeTagLongValue(long value, boolean offset, short type)
          Write the Tag's value to the stream as a 8byte int.
 void writeTagValue(int value, boolean offset, short type)
          Write the Tag's value to the stream.
 void writeUInt(int value)
          Write a LONG or SLONG.
 void writeULong(long value)
          Write a 8-byte signed/unsigned integer.
 void writeURational(int numerator, int denominator)
          Write a RATIONAL or SRATIONAL.
 void writeUShort(int value)
          Write a SHORT or SSHORT.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BYTE

public static final short BYTE
8-bit unsigned integer. In Java the only value that can be an unsigned 8-bit integer is an int.

See Also:
Constant Field Values

ASCII

public static final short ASCII
8-bit byte that contains a 7-bit ASCII code; the last byte must be NUL (binary zero), the last byte is taken care of by the Writer.

See Also:
Constant Field Values

SHORT

public static final short SHORT
16-bit (2-byte) unsigned integer. In Java the only value that can be an unsigned 16-bit integer is an int.

See Also:
Constant Field Values

LONG

public static final short LONG
32-bit (4-byte) unsigned integer. In Java the only value that can be an unsigned 32-bit integer is an int.

See Also:
Constant Field Values

RATIONAL

public static final short RATIONAL
Two LONGs: the first represents the numerator of a fraction; the second, the denominator.

See Also:
Constant Field Values

SBYTE

public static final short SBYTE
An 8-bit signed (twos-complement) integer.

See Also:
Constant Field Values

UNDEFINED

public static final short UNDEFINED
An 8-bit byte that may contain anything, depending on the definition of the field.

See Also:
Constant Field Values

SSHORT

public static final short SSHORT
A 16-bit (2-byte) signed (twos-complement) integer.

See Also:
Constant Field Values

SLONG

public static final short SLONG
A 32-bit (4-byte) signed (twos-complement) integer.

See Also:
Constant Field Values

SRATIONAL

public static final short SRATIONAL
Two SLONG’s: the first represents the numerator of a fraction, the second the denominator.

See Also:
Constant Field Values

FLOAT

public static final short FLOAT
Single precision (4-byte) IEEE format.

See Also:
Constant Field Values

DOUBLE

public static final short DOUBLE
Double precision (8-byte) IEEE format.

See Also:
Constant Field Values

LONG8

public static final short LONG8
A 64-bit (8-byte) unsigned integer.

See Also:
Constant Field Values

SLONG8

public static final short SLONG8
A 64-bit (8-byte) signed (twos-complement) integer.

See Also:
Constant Field Values
Constructor Detail

Writer

public Writer(boolean littleEndian,
              java.io.OutputStream out)
Create a new Writer.

Parameters:
littleEndian - If the stream should be little-endian (true) or big-endian (false).
out - The stream to write data to.
Method Detail

write

public void write(byte[] data)
           throws java.io.IOException
Write an array of bytes to the stream.

Parameters:
data - The array of bytes to write.
Throws:
java.io.IOException - If any IO exception occurs.

write

public void write(byte[] data,
                  int off,
                  int len)
           throws java.io.IOException
Write an array of bytes to the stream.

Parameters:
data - The array of bytes to write.
off - The start offset in the data.
len - The number of bytes to write.
Throws:
java.io.IOException - If any IO exception occurs.

writeByte

public void writeByte(int value)
               throws java.io.IOException
Write a BYTE or SBYTE.

Parameters:
value - The BYTE/SBYTE to write.
Throws:
java.io.IOException - If any IO exception occurs.

writeUShort

public void writeUShort(int value)
                 throws java.io.IOException
Write a SHORT or SSHORT.

Parameters:
value - The SHORT/SSHORT to write.
Throws:
java.io.IOException - If any IO exception occurs.

writeUInt

public void writeUInt(int value)
               throws java.io.IOException
Write a LONG or SLONG.

Parameters:
value - The LONG/SLONG to write.
Throws:
java.io.IOException - If any IO exception occurs.

writeFloat

public void writeFloat(float value)
                throws java.io.IOException
Write a FLOAT.

Parameters:
value - The FLOAT to write.
Throws:
java.io.IOException - If any IO exception occurs.

writeULong

public void writeULong(long value)
                throws java.io.IOException
Write a 8-byte signed/unsigned integer.

Parameters:
value - The 8-byte signed/unsigned integer to write.
Throws:
java.io.IOException - If any IO exception occurs.

writeDouble

public void writeDouble(double value)
                 throws java.io.IOException
Write a DOUBLE.

Parameters:
value - The DOUBLE to write.
Throws:
java.io.IOException - If any IO exception occurs.

writeURational

public void writeURational(int numerator,
                           int denominator)
                    throws java.io.IOException
Write a RATIONAL or SRATIONAL.

Parameters:
numerator - The numerator to write.
denominator - The denominator to write.
Throws:
java.io.IOException - If any IO exception occurs.

writeASCII

public void writeASCII(char value)
                throws java.io.IOException
Write a 7-bit ASCII code.

Parameters:
value - The 7-bit ASCII code to write.
Throws:
java.io.IOException - If any IO exception occurs.

writeASCII

public void writeASCII(java.lang.String value)
                throws java.io.IOException
Write a ASCII string.

Parameters:
value - The ASCII string to write.
Throws:
java.io.IOException - If any IO exception occurs.

writeASCII

public void writeASCII(java.lang.String[] values)
                throws java.io.IOException
Write an array of ASCII strings.

Parameters:
values - The array of ASCII strings to write.
Throws:
java.io.IOException - If any IO exception occurs.

getLittleEndian

public boolean getLittleEndian()
Get if the encoder is in little-endian format.

Returns:
true if in little-endian format, false if big-endian.

writeTagValue

public void writeTagValue(int value,
                          boolean offset,
                          short type)
                   throws java.io.IOException
Write the Tag's value to the stream.

Parameters:
value - The Tag's value.
offset - If the value is an offset.
type - The data type the value is.
Throws:
java.io.IOException

writeTagLongValue

public void writeTagLongValue(long value,
                              boolean offset,
                              short type)
                       throws java.io.IOException
Write the Tag's value to the stream as a 8byte int.

Parameters:
value - The Tag's value 8byte value.
offset - If the value is an offset.
type - The data type the value is.
Throws:
java.io.IOException

shiftValue

public static long shiftValue(int value,
                              int pos)
Shift a value so it is in a format that the Writer can write out.

Parameters:
value - The value to shift.
pos - The position it should be in the value (0-1).
Returns:
The shifted value.

shiftValue

public static long shiftValue(short value,
                              int pos)
Shift a value so it is in a format that the Writer can write out.

Parameters:
value - The value to shift.
pos - The position it should be in the value (0-3).
Returns:
The shifted value.

shiftValue

public static long shiftValue(byte value,
                              int pos)
Shift a value so it is in a format that the Writer can write out.

Parameters:
value - The value to shift.
pos - The position it should be in the value (0-7).
Returns:
The shifted value.

unshiftInt

public static int unshiftInt(long value,
                             int pos)
Unshift a value so it is in a format that is useable.

Parameters:
value - The value to "unshift."
pos - The position it is in the value (0-1).
Returns:
The unshifted value.

unshiftShort

public static short unshiftShort(long value,
                                 int pos)
Unshift a value so it is in a format that is useable.

Parameters:
value - The value to "unshift."
pos - The position it is in the value (0-3).
Returns:
The unshifted value.

unshiftByte

public static byte unshiftByte(long value,
                               int pos)
Unshift a value so it is in a format that is useable.

Parameters:
value - The value to "unshift."
pos - The position it is in the value (0-7).
Returns:
The unshifted value.