1 package abi47_0_0.expo.modules.imagemanipulator.arguments 2 3 import abi47_0_0.expo.modules.core.arguments.ReadableArguments 4 import android.graphics.Bitmap.CompressFormat 5 6 private const val KEY_BASE64 = "base64" 7 private const val KEY_COMPRESS = "compress" 8 private const val KEY_FORMAT = "format" 9 10 data class SaveOptions( 11 val base64: Boolean, 12 val compress: Double, 13 val format: CompressFormat 14 ) { 15 companion object { fromArgumentsnull16 fun fromArguments(arguments: ReadableArguments): SaveOptions { 17 val base64 = arguments.getBoolean(KEY_BASE64, false) 18 val compress = arguments.getDouble(KEY_COMPRESS, 1.0) 19 val format = toCompressFormat(arguments.getString(KEY_FORMAT, "jpeg")) 20 return SaveOptions(base64, compress, format) 21 } 22 } 23 } 24 toCompressFormatnull25fun toCompressFormat(format: String): CompressFormat { 26 return when (format) { 27 "jpeg" -> CompressFormat.JPEG 28 "png" -> CompressFormat.PNG 29 else -> CompressFormat.JPEG 30 } 31 } 32