Back to Fresco

EncodedImage

docs/javadoc/reference/com/facebook/imagepipeline/image/EncodedImage.html

3.6.025.7 KB
Original Source

Fresco

|

|

Packages | Classes

Interfaces

Classes

Enums

Packages | Classes

Summary: Constants | Ctors | Methods | Protected Methods | Inherited Methods | [Expand All]

public class

EncodedImage

extends Object
implements Closeable

| java.lang.Object | | ↳ | com.facebook.imagepipeline.image.EncodedImage |

Class Overview

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.

Summary

Constants
int
int
int
int
int
Public Constructors
Public Methods
EncodedImage
static EncodedImage
Returns the cloned encoded image if the parameter received is not null, null otherwise.
void
Closes the buffer enclosed by this class.
static void
Closes the encoded image handling null.
void
Copy the meta data from another EncodedImage.
CloseableReference<PooledByteBuffer>
Returns a cloned reference to the stored encoded bytes.
BytesRange
ColorSpace
The color space is always null if Android API level < 26.
int
Returns the exif orientation if known (1 - 8), else 0.
String
Returns first n bytes of encoded image as hexbytes
int
Returns the image height if known, else -1.
ImageFormat
Returns the image format if known, otherwise ImageFormat.UNKNOWN.
InputStream
Returns an InputStream from the internal InputStream Supplier if it's not null.
int
int
Only valid if the image format is JPEG.
int
Returns the size of the backing structure.
synchronized SharedReference<PooledByteBuffer>
A test-only method to get the underlying references.
int
Returns the image width if known, else -1.
boolean
Returns true if the image is a JPEG or DNG and its data is already complete at the specified length, false otherwise.
static boolean
Returns true if all the image information has loaded, false otherwise.
synchronized boolean
Returns true if the internal buffer reference is valid or the InputStream Supplier is not null, false otherwise.
static boolean
Checks if the encoded image is valid i.e.
void
void
void
Sets the exif orientation
void
Sets the image height
void
Sets the image format
void
Sets the image rotation angle
void
Sets the image sample size
void
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

| [Expand] Inherited Methods | | --- | | From class java.lang.Object

| Object | clone() | | boolean | equals(Object arg0) | | void | finalize() | | final Class<?> | getClass() | | int | hashCode() | | final void | notify() | | final void | notifyAll() | | String | toString() | | final void | wait(long arg0, int arg1) | | final void | wait(long arg0) | | final void | wait() |

| | From interface java.io.Closeable

| abstract void | close() |

| | From interface java.lang.AutoCloseable

| abstract void | close() |

|

Constants

public static final int DEFAULT_SAMPLE_SIZE

Constant Value: 1 (0x00000001)

public static final int UNKNOWN_HEIGHT

Constant Value: -1 (0xffffffff)

public static final int UNKNOWN_ROTATION_ANGLE

Constant Value: -1 (0xffffffff)

public static final int UNKNOWN_STREAM_SIZE

Constant Value: -1 (0xffffffff)

public static final int UNKNOWN_WIDTH

Constant Value: -1 (0xffffffff)

Public Constructors

public EncodedImage(CloseableReference<PooledByteBuffer> pooledByteBufferRef)

public EncodedImage(Supplier<FileInputStream> inputStreamSupplier)

public EncodedImage(Supplier<FileInputStream> inputStreamSupplier, int streamSize)

Public Methods

public EncodedImage cloneOrNull()

public static EncodedImage cloneOrNull(EncodedImage encodedImage)

Returns the cloned encoded image if the parameter received is not null, null otherwise.

Parameters

| encodedImage | the EncodedImage to clone |

public void close()

Closes the buffer enclosed by this class.

public static void closeSafely(EncodedImage encodedImage)

Closes the encoded image handling null.

Parameters

| encodedImage | the encoded image to close. |

public void copyMetaDataFrom(EncodedImage encodedImage)

Copy the meta data from another EncodedImage.

Parameters

| encodedImage | the EncodedImage to copy the meta data from. |

public CloseableReference<PooledByteBuffer> getByteBufferRef()

Returns a cloned reference to the stored encoded bytes.

The caller has to close the reference once it has finished using it.

public BytesRange getBytesRange()

public ColorSpace getColorSpace()

The color space is always null if Android API level < 26.

Returns
  • the color space of the image if known, else null.

public int getExifOrientation()

Returns the exif orientation if known (1 - 8), else 0.

public String getFirstBytesAsHexString(int length)

Returns first n bytes of encoded image as hexbytes

Parameters

| length | the number of bytes to return |

public int getHeight()

Returns the image height if known, else -1.

public ImageFormat getImageFormat()

Returns the image format if known, otherwise ImageFormat.UNKNOWN.

public InputStream getInputStream()

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.

public int getRotationAngle()

Returns
  • the rotation angle if the rotation angle is known, else -1. The rotation angle may not be known if the image is incomplete (e.g. for progressive JPEGs).

public int getSampleSize()

Only valid if the image format is JPEG.

Returns
  • sample size of the image.

public int getSize()

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.

public synchronized SharedReference<PooledByteBuffer> getUnderlyingReferenceTestOnly()

A test-only method to get the underlying references.

DO NOT USE in application code.

public int getWidth()

Returns the image width if known, else -1.

public 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.

public static boolean isMetaDataAvailable(EncodedImage encodedImage)

Returns true if all the image information has loaded, false otherwise.

public synchronized boolean isValid()

Returns true if the internal buffer reference is valid or the InputStream Supplier is not null, false otherwise.

public static boolean isValid(EncodedImage encodedImage)

Checks if the encoded image is valid i.e. is not null, and is not closed.

Returns
  • true if the encoded image is valid

public void parseMetaData()

public void setBytesRange(BytesRange bytesRange)

public void setExifOrientation(int exifOrientation)

Sets the exif orientation

public void setHeight(int height)

Sets the image height

public void setImageFormat(ImageFormat imageFormat)

Sets the image format

public void setRotationAngle(int rotationAngle)

Sets the image rotation angle

public void setSampleSize(int sampleSize)

Sets the image sample size

public void setStreamSize(int streamSize)

Sets the size of an image if backed by an InputStream

Ignored if backed by a ByteBuffer

public static void setUseCachedMetadata(boolean useCachedMetadata)

public void setWidth(int width)

Sets the image width

Protected Methods

protected boolean hasParsedMetaData()

+Generated by Doclava. +