Class ImageRef
-
- All Implemented Interfaces:
-
android.os.Parcelable,java.lang.AutoCloseable
public final class ImageRef implements Parcelable, AutoCloseable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classImageRef.CREATOR
-
Field Summary
Fields Modifier and Type Field Description private final UUIDuniqueIdpublic final static ImageRef.CREATORCREATOR
-
Method Summary
Modifier and Type Method Description final UUIDgetUniqueId()Unique id of the native resource the object points to. IntegerhashCode()Booleanequals(Object other)final ImageRefclone()Creates a deep copy of the image. final Unithibernate()Compresses ImageRef and stores it either on disk or in memory according to global settings. final Unitclear()Releases native resources stored by the ref. final ImageInfoinfo()Information about stored image. final BitmaptoBitmap()Returns stored image as a bitmap final BooleansaveImage(String path, SaveImageOptions options)Saves the stored image with the given options. final ByteArrayencodeImage(EncodeImageOptions options)Returns the stored image encoded with the given options. Unitclose()Releases strong reference to the image IntegerdescribeContents()UnitwriteToParcel(Parcel parcel, Integer flags)final Stringserialize()Converts ImageRef to serialized string representation with acquiring serialized reference to the native resource. final JSONObjecttoJson(ImageSerializationMode imageSerializationMode)Converts the Image Ref to Json representation If serialization mode is REFERENCE effectively calls serialize If serialization mode is BUFFER stores the image inplace in base64 format final static UnitreleaseAllImages()Releases all alive images despite any existing references. final static ImageReffromEncodedBuffer(ByteArray encodedBuffer, BufferImageLoadOptions options)Creates ImageRef from encoded buffer, e.g. final static ImageReffromInputStream(InputStream inputStream, BufferImageLoadOptions options)Creates ImageRef from the given input stream of encoded bytes final static ImageReffromPath(String path, PathImageLoadOptions options)Creates ImageRef from the path to an image. final static ImageReffromBitmap(Bitmap bitmap, BasicImageLoadOptions options)Creates ImageRef from a bitmap. final static ImageReffromNv21(ByteArray nv21, Integer width, Integer height, RawImageLoadOptions options)Creates ImageRef from nv21 bytes final static ImageRefdeserialize(String source)Creates ImageRef from serialized string representation with upgrading serialized reference to a strong one final static ImageReffromSerializedReference(UUID uniqueId)final static ImageReffromJson(Map<String, Object> source)final static ImageReffromJson(JSONObject source)final static UnitsetHibernationJpegQuality(Integer quality)Sets the quality of JPEG compression used to encode images when hibernating. final static UnitsetHibernationCacheDirPath(String cacheDirPath)Sets directory in which hibernated images are stored. final static UnitsetStorageCryptingProvider(CoreStreamProvider storageCryptingProvider)Sets storageCryptingProvider that is used when an image is read/written from/to disk. final static BooleanacquireSerializedReference(UUID uniqueId)final static BooleanreleaseStrongReference(UUID uniqueId)final static BooleanupgradeSerializedReference(UUID uniqueId)-
-
Method Detail
-
getUniqueId
final UUID getUniqueId()
Unique id of the native resource the object points to.
-
hibernate
final Unit hibernate()
Compresses ImageRef and stores it either on disk or in memory according to global settings.
-
clear
final Unit clear()
Releases native resources stored by the ref. If two different ImageRef objects have the same uniqueId both of them become cleared.
-
saveImage
final Boolean saveImage(String path, SaveImageOptions options)
Saves the stored image with the given options.
-
encodeImage
final ByteArray encodeImage(EncodeImageOptions options)
Returns the stored image encoded with the given options.
-
describeContents
Integer describeContents()
-
writeToParcel
Unit writeToParcel(Parcel parcel, Integer flags)
-
serialize
final String serialize()
Converts ImageRef to serialized string representation with acquiring serialized reference to the native resource. You must eventually call deserialize, otherwise the reference will leak
-
toJson
final JSONObject toJson(ImageSerializationMode imageSerializationMode)
Converts the Image Ref to Json representation If serialization mode is REFERENCE effectively calls serialize If serialization mode is BUFFER stores the image inplace in base64 format
-
releaseAllImages
final static Unit releaseAllImages()
Releases all alive images despite any existing references.
-
fromEncodedBuffer
final static ImageRef fromEncodedBuffer(ByteArray encodedBuffer, BufferImageLoadOptions options)
Creates ImageRef from encoded buffer, e.g. from jpeg.
-
fromInputStream
final static ImageRef fromInputStream(InputStream inputStream, BufferImageLoadOptions options)
Creates ImageRef from the given input stream of encoded bytes
-
fromPath
final static ImageRef fromPath(String path, PathImageLoadOptions options)
Creates ImageRef from the path to an image.
-
fromBitmap
final static ImageRef fromBitmap(Bitmap bitmap, BasicImageLoadOptions options)
Creates ImageRef from a bitmap.
-
fromNv21
final static ImageRef fromNv21(ByteArray nv21, Integer width, Integer height, RawImageLoadOptions options)
Creates ImageRef from nv21 bytes
-
deserialize
final static ImageRef deserialize(String source)
Creates ImageRef from serialized string representation with upgrading serialized reference to a strong one
-
fromSerializedReference
final static ImageRef fromSerializedReference(UUID uniqueId)
-
fromJson
final static ImageRef fromJson(JSONObject source)
-
setHibernationJpegQuality
final static Unit setHibernationJpegQuality(Integer quality)
Sets the quality of JPEG compression used to encode images when hibernating. The default is 80.
-
setHibernationCacheDirPath
final static Unit setHibernationCacheDirPath(String cacheDirPath)
Sets directory in which hibernated images are stored. If null is passed, then hibernated images are stored in compressed format in memory. Can be set at most once, best when the application is initialized but in any case before any ImageRef is created.
-
setStorageCryptingProvider
final static Unit setStorageCryptingProvider(CoreStreamProvider storageCryptingProvider)
Sets storageCryptingProvider that is used when an image is read/written from/to disk. The provider is used both when images are hibernated and when they are saved/loaded from disk with saveImage/fromPath. Can be set at most once, best when the application is initialized but in any case before any ImageRef is created.
-
acquireSerializedReference
final static Boolean acquireSerializedReference(UUID uniqueId)
-
releaseStrongReference
final static Boolean releaseStrongReference(UUID uniqueId)
-
upgradeSerializedReference
final static Boolean upgradeSerializedReference(UUID uniqueId)
-
-
-
-