feat: add Bitmap to Base64 conversion extension
This commit is contained in:
parent
1230d015ce
commit
f4a23460d1
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.syaroful.agrilinkvocpro.plant_disease_detection_feature.core.extention
|
||||||
|
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import android.util.Base64
|
||||||
|
import java.io.ByteArrayOutputStream
|
||||||
|
|
||||||
|
fun Bitmap.toBase64(): String {
|
||||||
|
val stream = ByteArrayOutputStream()
|
||||||
|
this.compress(Bitmap.CompressFormat.JPEG, 100, stream)
|
||||||
|
val byteArray = stream.toByteArray()
|
||||||
|
return Base64.encodeToString(byteArray, Base64.NO_WRAP)
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user