Class Predictor.PredictorOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable
    Enclosing class:
    Predictor

    private static final class Predictor.PredictorOutputStream
    extends java.io.FilterOutputStream
    Output stream that implements predictor decoding. Data is buffered until a complete row is available, which is then decoded and written to the underlying stream. The previous row is retained for decoding the next row.
    • Constructor Summary

      Constructors 
      Constructor Description
      PredictorOutputStream​(java.io.OutputStream out, int predictor, int colors, int bitsPerComponent, int columns)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void decodeAndWriteRow()  
      private void flipRows()
      Flips the row buffers (to avoid copying), and resets the current-row index and predictorRead flag
      void flush()  
      void write​(byte[] bytes)  
      void write​(byte[] bytes, int off, int len)  
      void write​(int i)  
      • Methods inherited from class java.io.FilterOutputStream

        close
      • Methods inherited from class java.io.OutputStream

        nullOutputStream
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • predictor

        private int predictor
      • colors

        private final int colors
      • bitsPerComponent

        private final int bitsPerComponent
      • columns

        private final int columns
      • rowLength

        private final int rowLength
      • predictorPerRow

        private final boolean predictorPerRow
      • currentRow

        private byte[] currentRow
      • lastRow

        private byte[] lastRow
      • currentRowData

        private int currentRowData
      • predictorRead

        private boolean predictorRead
    • Constructor Detail

      • PredictorOutputStream

        PredictorOutputStream​(java.io.OutputStream out,
                              int predictor,
                              int colors,
                              int bitsPerComponent,
                              int columns)
    • Method Detail

      • write

        public void write​(byte[] bytes)
                   throws java.io.IOException
        Overrides:
        write in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] bytes,
                          int off,
                          int len)
                   throws java.io.IOException
        Overrides:
        write in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • decodeAndWriteRow

        private void decodeAndWriteRow()
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • flipRows

        private void flipRows()
        Flips the row buffers (to avoid copying), and resets the current-row index and predictorRead flag
      • flush

        public void flush()
                   throws java.io.IOException
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(int i)
                   throws java.io.IOException
        Overrides:
        write in class java.io.FilterOutputStream
        Throws:
        java.io.IOException