Class CroppedImageInputByteStream

  • All Implemented Interfaces:
    InputByteStream

    public class CroppedImageInputByteStream
    extends Object
    implements InputByteStream
    This class is used to crop an image input stream to specified bounds. This particularly is helpful for those images which are very huge. Because we never load the complete image in memory at any moment. There are some methods which are either not supported or not follow the contract of InputByteStream. So, clients are recommended to read the javadocs of individual API's of this class before using them.
    • Constructor Detail

      • CroppedImageInputByteStream

        public CroppedImageInputByteStream​(int bpc,
                                           int noc,
                                           InputStream decodedImage,
                                           int width,
                                           int height,
                                           int x1,
                                           int y1,
                                           int x2,
                                           int y2)
                                    throws IOException
        Constructor to create an instance of this InputByteStream which reads subimage of dimension (x2-x1)*(y2-y1), of specified bits per component and number of components, from passed InputStream
        Parameters:
        bpc - bits per component of image
        noc - number of components
        decodedImage - image input stream
        width - image width
        height - image height
        x1 - left
        y1 - bottom
        x2 - right
        y2 - top
        Throws:
        IOException
    • Method Detail

      • slice

        public InputByteStream slice​(long begin,
                                     long length)
                              throws IOException
        Not supported
        Specified by:
        slice in interface InputByteStream
        Parameters:
        begin - Offset within the current InputByteStream to start the slice.
        length - The length of the slice.
        Returns:
        A slice of the original InputByteStream.
        Throws:
        IOException
      • read

        public int read()
                 throws IOException
        Description copied from interface: InputByteStream
        Only for internal engineering use. This api can change without notice. Read the byte at the current position. If the current position is at or beyond the end of the underlying data return a -1. If not beyond the end of the underlying data the current position is incremented by 1.
        Specified by:
        read in interface InputByteStream
        Returns:
        The byte at the current position or -1 if at or beyond EOF.
        Throws:
        IOException
      • read

        public int read​(byte[] bytes,
                        int position,
                        int length)
                 throws IOException
        Description copied from interface: InputByteStream
        Only for internal engineering use. This api can change without notice. Read an array of bytes starting at the current position. The position is incremented by the length of the array that has been read.
        Specified by:
        read in interface InputByteStream
        Parameters:
        bytes - The destination array.
        position - The offset in the byte array to put the first byte read.
        length - The number of bytes to read.
        Throws:
        IOException
      • read

        public int read​(byte[] bytes)
                 throws IOException
        Description copied from interface: InputByteStream
        Only for internal engineering use. This api can change without notice. Read an array of bytes starting at the current position. The position is incremented by the length of the array that has been read.
        Specified by:
        read in interface InputByteStream
        Parameters:
        bytes - The destination array.
        Throws:
        IOException
      • getPosition

        public long getPosition()
                         throws IOException
        Description copied from interface: InputByteStream
        Only for internal engineering use. This api can change without notice. Get the current position.
        Specified by:
        getPosition in interface InputByteStream
        Returns:
        The current position.
        Throws:
        IOException
      • length

        public long length()
                    throws IOException
        Description copied from interface: InputByteStream
        Only for internal engineering use. This api can change without notice. The maximum number of bytes that can be read from this InputByteStream.
        Specified by:
        length in interface InputByteStream
        Returns:
        Total number of bytes available in this InputByteStream.
        Throws:
        IOException
      • bytesAvailable

        public long bytesAvailable()
                            throws IOException
        Description copied from interface: InputByteStream
        Only for internal engineering use. This api can change without notice. The number of bytes available to be read from the current position.
        Specified by:
        bytesAvailable in interface InputByteStream
        Returns:
        Number of bytes available from the current position in this InputByteStream.
        Throws:
        IOException
      • eof

        public boolean eof()
                    throws IOException
        Description copied from interface: InputByteStream
        Only for internal engineering use. This api can change without notice. Is the current position of this InputByteStream at or beyond the end of the underlying data.
        Specified by:
        eof in interface InputByteStream
        Returns:
        True if the current position is beyond the end of the underlying data, false otherwise.
        Throws:
        IOException
      • close

        public void close()
                   throws IOException
        Description copied from interface: InputByteStream
        Closes this InputByteStream and releases any system resources associated with the stream. After this method is called then any further calls to this instance are errors.
        Specified by:
        close in interface InputByteStream
        Throws:
        IOException