Class AbstractRLEDecoder

java.lang.Object
com.twelvemonkeys.imageio.plugins.bmp.AbstractRLEDecoder
All Implemented Interfaces:
Decoder
Direct Known Subclasses:
RLE4Decoder, RLE8Decoder

abstract class AbstractRLEDecoder extends Object implements Decoder
Abstract base class for RLE decoding as specified by in the Windows BMP (aka DIB) file format.
Version:
$Id: AbstractRLEDecoder.java#1 $
  • Field Details

    • width

      protected final int width
    • bitsPerSample

      protected final int bitsPerSample
    • row

      protected final byte[] row
    • srcX

      protected int srcX
    • srcY

      protected int srcY
    • dstX

      protected int dstX
    • dstY

      protected int dstY
  • Constructor Details

    • AbstractRLEDecoder

      AbstractRLEDecoder(int width, int bitsPerSample)
      Creates an RLEDecoder. As RLE encoded BMPs may contain x and y deltas, etc, we need to know height and width of the image.
      Parameters:
      width - width of the image
      bitsPerSample - pits per sample
  • Method Details

    • decodeRow

      protected abstract void decodeRow(InputStream stream) throws IOException
      Decodes one full row of image data.
      Parameters:
      stream - the input stream containing RLE data
      Throws:
      IOException - if an I/O related exception occurs while reading
    • decode

      public final int decode(InputStream stream, ByteBuffer buffer) throws IOException
      Decodes as much data as possible, from the stream into the buffer.
      Specified by:
      decode in interface Decoder
      Parameters:
      stream - the input stream containing RLE data
      buffer - the buffer to decode the data to
      Returns:
      the number of bytes decoded from the stream, to the buffer
      Throws:
      IOException - if an I/O related exception occurs while reading
    • checkEOF

      protected static int checkEOF(int val) throws EOFException
      Checks a read byte for EOF marker.
      Parameters:
      val - the byte to check
      Returns:
      the value of val if positive.
      Throws:
      EOFException - if val is negative