java.lang.Object | |
↳ | com.facebook.imagepipeline.image.EncodedImage |
Class that contains all the information for an encoded image, both the image bytes (held on a byte buffer or a supplier of input streams) and the extracted meta data that is useful for image transforms.
Only one of the input stream supplier or the byte buffer can be set. If using an input stream supplier, the methods that return a byte buffer will simply return null. However, getInputStream will always be supported, either from the supplier or an input stream created from the byte buffer held.
Currently the data is useful for rotation and resize.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | DEFAULT_SAMPLE_SIZE | ||||||||||
int | UNKNOWN_HEIGHT | ||||||||||
int | UNKNOWN_ROTATION_ANGLE | ||||||||||
int | UNKNOWN_STREAM_SIZE | ||||||||||
int | UNKNOWN_WIDTH |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
EncodedImage(CloseableReference<PooledByteBuffer> pooledByteBufferRef) | |||||||||||
EncodedImage(Supplier<FileInputStream> inputStreamSupplier) | |||||||||||
EncodedImage(Supplier<FileInputStream> inputStreamSupplier, int streamSize) |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
EncodedImage | cloneOrNull() | ||||||||||
static EncodedImage |
cloneOrNull(EncodedImage encodedImage)
Returns the cloned encoded image if the parameter received is not null, null otherwise.
| ||||||||||
void |
close()
Closes the buffer enclosed by this class.
| ||||||||||
static void |
closeSafely(EncodedImage encodedImage)
Closes the encoded image handling null.
| ||||||||||
void |
copyMetaDataFrom(EncodedImage encodedImage)
Copy the meta data from another EncodedImage.
| ||||||||||
CloseableReference<PooledByteBuffer> |
getByteBufferRef()
Returns a cloned reference to the stored encoded bytes.
| ||||||||||
BytesRange | getBytesRange() | ||||||||||
ColorSpace |
getColorSpace()
The color space is always null if Android API level < 26.
| ||||||||||
int |
getExifOrientation()
Returns the exif orientation if known (1 - 8), else 0.
| ||||||||||
String |
getFirstBytesAsHexString(int length)
Returns first n bytes of encoded image as hexbytes
| ||||||||||
int |
getHeight()
Returns the image height if known, else -1.
| ||||||||||
ImageFormat |
getImageFormat()
Returns the image format if known, otherwise ImageFormat.UNKNOWN.
| ||||||||||
InputStream |
getInputStream()
Returns an InputStream from the internal InputStream Supplier if it's not null.
| ||||||||||
int | getRotationAngle() | ||||||||||
int |
getSampleSize()
Only valid if the image format is JPEG.
| ||||||||||
int |
getSize()
Returns the size of the backing structure.
| ||||||||||
synchronized SharedReference<PooledByteBuffer> |
getUnderlyingReferenceTestOnly()
A test-only method to get the underlying references.
| ||||||||||
int |
getWidth()
Returns the image width if known, else -1.
| ||||||||||
boolean |
isCompleteAt(int length)
Returns true if the image is a JPEG or DNG and its data is already complete at the specified
length, false otherwise.
| ||||||||||
static boolean |
isMetaDataAvailable(EncodedImage encodedImage)
Returns true if all the image information has loaded, false otherwise.
| ||||||||||
synchronized boolean |
isValid()
Returns true if the internal buffer reference is valid or the InputStream Supplier is not null,
false otherwise.
| ||||||||||
static boolean |
isValid(EncodedImage encodedImage)
Checks if the encoded image is valid i.e.
| ||||||||||
void | parseMetaData() | ||||||||||
void | setBytesRange(BytesRange bytesRange) | ||||||||||
void |
setExifOrientation(int exifOrientation)
Sets the exif orientation
| ||||||||||
void |
setHeight(int height)
Sets the image height
| ||||||||||
void |
setImageFormat(ImageFormat imageFormat)
Sets the image format
| ||||||||||
void |
setRotationAngle(int rotationAngle)
Sets the image rotation angle
| ||||||||||
void |
setSampleSize(int sampleSize)
Sets the image sample size
| ||||||||||
void |
setStreamSize(int streamSize)
Sets the size of an image if backed by an InputStream
Ignored if backed by a ByteBuffer | ||||||||||
static void | setUseCachedMetadata(boolean useCachedMetadata) | ||||||||||
void |
setWidth(int width)
Sets the image width
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
boolean | hasParsedMetaData() |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.io.Closeable
| |||||||||||
From interface
java.lang.AutoCloseable
|
Returns the cloned encoded image if the parameter received is not null, null otherwise.
encodedImage | the EncodedImage to clone |
---|
Closes the buffer enclosed by this class.
Closes the encoded image handling null.
encodedImage | the encoded image to close. |
---|
Copy the meta data from another EncodedImage.
encodedImage | the EncodedImage to copy the meta data from. |
---|
Returns a cloned reference to the stored encoded bytes.
The caller has to close the reference once it has finished using it.
The color space is always null if Android API level < 26.
Returns the exif orientation if known (1 - 8), else 0.
Returns first n bytes of encoded image as hexbytes
length | the number of bytes to return |
---|
Returns the image height if known, else -1.
Returns the image format if known, otherwise ImageFormat.UNKNOWN.
Returns an InputStream from the internal InputStream Supplier if it's not null. Otherwise returns an InputStream for the internal buffer reference if valid and null otherwise.
The caller has to close the InputStream after using it.
Only valid if the image format is JPEG.
Returns the size of the backing structure.
If it's a PooledByteBuffer returns its size if its not null, -1 otherwise. If it's an InputStream, return the size if it was set, -1 otherwise.
A test-only method to get the underlying references.
DO NOT USE in application code.
Returns the image width if known, else -1.
Returns true if the image is a JPEG or DNG and its data is already complete at the specified length, false otherwise.
Returns true if all the image information has loaded, false otherwise.
Returns true if the internal buffer reference is valid or the InputStream Supplier is not null, false otherwise.
Checks if the encoded image is valid i.e. is not null, and is not closed.
Sets the exif orientation
Sets the image height
Sets the image rotation angle
Sets the image sample size
Sets the size of an image if backed by an InputStream
Ignored if backed by a ByteBuffer
Sets the image width