Package com.adobe.internal.io.stream
Class CroppedImageInputByteStream
- java.lang.Object
-
- com.adobe.internal.io.stream.CroppedImageInputByteStream
-
- All Implemented Interfaces:
InputByteStream
public class CroppedImageInputByteStream extends java.lang.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 ofInputByteStream
. So, clients are recommended to read the javadocs of individual API's of this class before using them.
-
-
Field Summary
-
Fields inherited from interface com.adobe.internal.io.stream.InputByteStream
EOF
-
-
Constructor Summary
Constructors Constructor Description CroppedImageInputByteStream(int bpc, int noc, java.io.InputStream decodedImage, int width, int height, int x1, int y1, int x2, int y2)
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 passedInputStream
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
bytesAvailable()
Only for internal engineering use.void
close()
Closes this InputByteStream and releases any system resources associated with the stream.boolean
eof()
Only for internal engineering use.long
getPosition()
Only for internal engineering use.long
length()
Only for internal engineering use.int
read()
Only for internal engineering use.int
read(byte[] bytes)
Only for internal engineering use.int
read(byte[] bytes, int position, int length)
Only for internal engineering use.InputByteStream
seek(long position)
Not supportedInputByteStream
slice()
Returns itself.InputByteStream
slice(long begin, long length)
Not supportedjava.io.InputStream
toInputStream()
Returns an instance ofInputStream
which uses this stream only as back-end.int
unget()
Not supported
-
-
-
Constructor Detail
-
CroppedImageInputByteStream
public CroppedImageInputByteStream(int bpc, int noc, java.io.InputStream decodedImage, int width, int height, int x1, int y1, int x2, int y2) throws java.io.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 passedInputStream
- Parameters:
bpc
- bits per component of imagenoc
- number of componentsdecodedImage
- image input streamwidth
- image widthheight
- image heightx1
- lefty1
- bottomx2
- righty2
- top- Throws:
java.io.IOException
-
-
Method Detail
-
slice
public InputByteStream slice(long begin, long length) throws java.io.IOException
Not supported- Specified by:
slice
in interfaceInputByteStream
- Parameters:
begin
- Offset within the currentInputByteStream
to start the slice.length
- The length of the slice.- Returns:
- A slice of the original
InputByteStream
. - Throws:
java.io.IOException
-
slice
public InputByteStream slice() throws java.io.IOException
Returns itself.- Specified by:
slice
in interfaceInputByteStream
- Returns:
- A slice of the original
InputByteStream
. - Throws:
java.io.IOException
-
read
public int read() throws java.io.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 interfaceInputByteStream
- Returns:
- The byte at the current position or
-1
if at or beyond EOF. - Throws:
java.io.IOException
-
read
public int read(byte[] bytes, int position, int length) throws java.io.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 interfaceInputByteStream
- 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:
java.io.IOException
-
read
public int read(byte[] bytes) throws java.io.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 interfaceInputByteStream
- Parameters:
bytes
- The destination array.- Throws:
java.io.IOException
-
unget
public int unget() throws java.io.IOException
Not supported- Specified by:
unget
in interfaceInputByteStream
- Throws:
java.io.IOException
-
seek
public InputByteStream seek(long position) throws java.io.IOException
Not supported- Specified by:
seek
in interfaceInputByteStream
- Parameters:
position
- Where to set the current position.- Returns:
- This object.
- Throws:
java.io.IOException
-
getPosition
public long getPosition() throws java.io.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 interfaceInputByteStream
- Returns:
- The current position.
- Throws:
java.io.IOException
-
length
public long length() throws java.io.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 thisInputByteStream
.- Specified by:
length
in interfaceInputByteStream
- Returns:
- Total number of bytes available in this
InputByteStream
. - Throws:
java.io.IOException
-
bytesAvailable
public long bytesAvailable() throws java.io.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 interfaceInputByteStream
- Returns:
- Number of bytes available from the current position in this
InputByteStream
. - Throws:
java.io.IOException
-
eof
public boolean eof() throws java.io.IOException
Description copied from interface:InputByteStream
Only for internal engineering use. This api can change without notice. Is the current position of thisInputByteStream
at or beyond the end of the underlying data.- Specified by:
eof
in interfaceInputByteStream
- Returns:
- True if the current position is beyond the end of the underlying data, false otherwise.
- Throws:
java.io.IOException
-
close
public void close() throws java.io.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 interfaceInputByteStream
- Throws:
java.io.IOException
-
toInputStream
public java.io.InputStream toInputStream() throws java.io.IOException
Returns an instance ofInputStream
which uses this stream only as back-end. So, closing one of them will close the other also.- Specified by:
toInputStream
in interfaceInputByteStream
- Returns:
- an InputStream that refers to the same underlying data
- Throws:
java.io.IOException
-
-