Package-level declarations

Types

Link copied to clipboard

Output format used during compression.

Link copied to clipboard
data class ImageCompressionOptions(val format: ImageCompressionFormat = ImageCompressionFormat.JPEG, val quality: Int = 90, val maxBytes: Long? = null, val minQuality: Int = 55, val qualityStep: Int = 5)

Options that control image compression.

Link copied to clipboard
data class ImageData(val bytes: ByteArray?)

A container class representing a loaded image.

Link copied to clipboard
data class WindowSize(val width: Int, val height: Int)

Functions

Link copied to clipboard
fun calculateInSampleSize(options: BitmapFactory.Options, reqHeight: Int, reqWidth: Int): Int
fun calculateInSampleSize(srcWidth: Int, srcHeight: Int, reqWidth: Int, reqHeight: Int): Int
Link copied to clipboard
fun ImageData.compress(options: ImageCompressionOptions = ImageCompressionOptions()): ImageData

Returns a compressed copy of this ImageData.

Link copied to clipboard
expect fun ByteArray.compressImage(options: ImageCompressionOptions = ImageCompressionOptions()): ByteArray

Compresses this ByteArray if it contains a supported image.

actual fun ByteArray.compressImage(options: ImageCompressionOptions): ByteArray
Link copied to clipboard
fun ImageData.compressToMaxBytes(maxBytes: Long, format: ImageCompressionFormat = ImageCompressionFormat.JPEG, quality: Int = 90, minQuality: Int = 55, qualityStep: Int = 5): ImageData

Compresses this ImageData toward the provided maximum size.

fun ByteArray.compressToMaxBytes(maxBytes: Long, format: ImageCompressionFormat = ImageCompressionFormat.JPEG, quality: Int = 90, minQuality: Int = 55, qualityStep: Int = 5): ByteArray

Compresses this ByteArray toward the provided maximum size.

Link copied to clipboard
fun decodeSampledBitmapFromUri(context: Context, uri: Uri, reqResolution: WindowSize): Job
Link copied to clipboard
actual suspend fun ByteArray.downSamplingToImageBitmap(coroutineScope: CoroutineScope, reqHeight: Int, reqWidth: Int): ImageBitmap?
expect suspend fun ByteArray.downSamplingToImageBitmap(coroutineScope: CoroutineScope, reqHeight: Int, reqWidth: Int): ImageBitmap?

Returns a bitmap with down sampling for the current screen size.

actual suspend fun ByteArray.downSamplingToImageBitmap(coroutineScope: CoroutineScope, reqHeight: Int, reqWidth: Int): ImageBitmap?
actual suspend fun ByteArray.downSamplingToImageBitmap(coroutineScope: CoroutineScope, reqHeight: Int, reqWidth: Int): ImageBitmap?
Link copied to clipboard
Link copied to clipboard
actual fun getCurrentWindowSize(): WindowSize
Link copied to clipboard
actual suspend fun selectImage(loadingState: (Boolean) -> Unit): ImageData?
expect suspend fun selectImage(loadingState: (Boolean) -> Unit = {}): ImageData?

Opens the platform's image picker and returns the selected ImageData, or null if the user cancels the selection. The image isn't loaded in the memory in its actual size, it's downsampled according to the current window size of the app and then loaded into memory as ImageData which is lower than the actual size eliminating the possibility of OutOfMemoryError

actual suspend fun selectImage(loadingState: (Boolean) -> Unit): ImageData?
actual suspend fun selectImage(loadingState: (Boolean) -> Unit): ImageData?
Link copied to clipboard
Link copied to clipboard

Converts this ImageBitmap into a ByteArray

Link copied to clipboard

Converts this ByteArray into an ImageBitmap.

Link copied to clipboard
fun ImageBitmap.withAspectRatio(aspectRatio: Float, scale: Boolean = false, targetHeight: Int? = null): ImageBitmap

Adjusts this ImageBitmap to a target aspect ratio.