Class IFFOutputStream

java.lang.Object
java.io.OutputStream
org.monte.media.iff.IFFOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class IFFOutputStream extends OutputStream
Facilitates writing of EA 85 IFF files.

Reference:
Commodore-Amiga, Inc. (1991) Amiga ROM Kernel Reference Manual. Devices. Third Edition. Reading: Addison-Wesley.

Author:
Werner Randelshofer
  • Constructor Details

  • Method Details

    • pushCompositeChunk

      public void pushCompositeChunk(int compositeType, int chunkType) throws IOException
      Throws:
      IOException
    • pushCompositeChunk

      public void pushCompositeChunk(String compositeType, String chunkType) throws IOException
      Throws:
      IOException
    • pushDataChunk

      public void pushDataChunk(int chunkType) throws IOException
      Throws:
      IOException
    • pushDataChunk

      public void pushDataChunk(String chunkType) throws IOException
      Throws:
      IOException
    • popChunk

      public void popChunk() throws IOException
      Throws:
      IOException
    • finish

      public void finish() throws IOException
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class OutputStream
      Throws:
      IOException
    • write

      public void write(byte[] b, int off, int len) throws IOException
      Overrides:
      write in class OutputStream
      Throws:
      IOException
    • write

      public void write(int b) throws IOException
      Specified by:
      write in class OutputStream
      Throws:
      IOException
    • getStreamPosition

      public long getStreamPosition() throws IOException
      Gets the position relative to the beginning of the IFF output stream.

      Usually this value is equal to the stream position of the underlying ImageOutputStream, but can be larger if the underlying stream already contained data.

      Returns:
      The relative stream position.
      Throws:
      IOException
    • seek

      public void seek(long newPosition) throws IOException
      Seeks relative to the beginning of the IFF output stream.

      Usually this equal to seeking in the underlying ImageOutputStream, but can be different if the underlying stream already contained data.

      Throws:
      IOException
    • writeLONG

      public void writeLONG(int v) throws IOException
      Throws:
      IOException
    • writeULONG

      public void writeULONG(long v) throws IOException
      Throws:
      IOException
    • writeWORD

      public void writeWORD(int v) throws IOException
      Throws:
      IOException
    • writeUWORD

      public void writeUWORD(int v) throws IOException
      Throws:
      IOException
    • writeUBYTE

      public void writeUBYTE(int v) throws IOException
      Throws:
      IOException
    • writeTYPE

      public void writeTYPE(String s) throws IOException
      Writes an chunk type identifier (4 bytes).
      Parameters:
      s - A string with a length of 4 characters.
      Throws:
      IOException
    • writeByteRun1

      public void writeByteRun1(byte[] data) throws IOException
      ByteRun1 Run Encoding.

      The run encoding scheme in byteRun1 is best described by pseudo code for the decoder Unpacker (called UnPackBits in the Macintosh toolbox):

       UnPacker:
          LOOP until produced the desired number of bytes
             Read the next source byte into n
             SELECT n FROM
                [ 0..127 ] ⇒ copy the next n+1 bytes literally
                [-1..-127] ⇒ replicate the next byte -n+1 timees
                -128       ⇒ no operation
             ENDCASE
          ENDLOOP
       
      Throws:
      IOException
    • writeByteRun1

      public void writeByteRun1(byte[] data, int offset, int length) throws IOException
      Throws:
      IOException