Fixes tests
This commit is contained in:
+2
-10
@@ -25,18 +25,10 @@ import android.graphics.BitmapFactory
|
||||
import com.vitorpamplona.amethyst.commons.blurhash.PlatformImage
|
||||
import com.vitorpamplona.amethyst.commons.blurhash.toPlatformImage
|
||||
import com.vitorpamplona.amethyst.commons.richtext.Base64Image
|
||||
import java.util.Base64
|
||||
|
||||
fun Base64Image.toBitmap(content: String): Bitmap {
|
||||
val matcher = pattern.matcher(content)
|
||||
|
||||
if (matcher.find()) {
|
||||
val base64String = matcher.group(2)
|
||||
val byteArray = Base64.getDecoder().decode(base64String)
|
||||
return BitmapFactory.decodeByteArray(byteArray, 0, byteArray.size)
|
||||
}
|
||||
|
||||
throw Exception("Unable to convert base64 to image $content")
|
||||
val byteArray = parse(content)
|
||||
return BitmapFactory.decodeByteArray(byteArray, 0, byteArray.size)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user