Fixed that toComposeImageBitmap() is not available on Android
This commit is contained in:
parent
b738ddaefa
commit
edd66d807d
|
@ -0,0 +1,8 @@
|
|||
package net.codinux.banking.ui.service
|
||||
|
||||
import android.graphics.BitmapFactory
|
||||
import androidx.compose.ui.graphics.ImageBitmap
|
||||
import androidx.compose.ui.graphics.asImageBitmap
|
||||
|
||||
actual fun createImageBitmap(imageBytes: ByteArray): ImageBitmap =
|
||||
BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.size).asImageBitmap()
|
|
@ -12,7 +12,6 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.toComposeImageBitmap
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
@ -26,7 +25,6 @@ import net.codinux.banking.ui.model.TanChallengeReceived
|
|||
import net.codinux.log.Log
|
||||
import org.jetbrains.compose.resources.imageResource
|
||||
import org.jetbrains.compose.ui.tooling.preview.Preview
|
||||
import org.jetbrains.skia.Image
|
||||
import kotlin.io.encoding.Base64
|
||||
import kotlin.io.encoding.ExperimentalEncodingApi
|
||||
import bankmeister.composeapp.generated.resources.zoom_in
|
||||
|
@ -140,8 +138,7 @@ fun EnterTanDialog(tanChallengeReceived: TanChallengeReceived, onDismiss: () ->
|
|||
|
||||
challenge.tanImage?.let { tanImage ->
|
||||
if (tanImage.decodingSuccessful) {
|
||||
val byteArray = Base64.decode(tanImage.imageBytesBase64)
|
||||
val bitmap = Image.makeFromEncoded(byteArray)
|
||||
val imageBytes = Base64.decode(tanImage.imageBytesBase64)
|
||||
|
||||
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically) {
|
||||
Text("Größe")
|
||||
|
@ -154,7 +151,7 @@ fun EnterTanDialog(tanChallengeReceived: TanChallengeReceived, onDismiss: () ->
|
|||
}
|
||||
|
||||
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically) {
|
||||
Image(bitmap.toComposeImageBitmap(), "Bild mit enkodierter TAN", Modifier.height(tanImageHeight.dp), contentScale = ContentScale.FillHeight)
|
||||
Image(createImageBitmap(imageBytes), "Bild mit enkodierter TAN", Modifier.height(tanImageHeight.dp), contentScale = ContentScale.FillHeight)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package net.codinux.banking.ui.service
|
||||
|
||||
import androidx.compose.ui.graphics.ImageBitmap
|
||||
|
||||
expect fun createImageBitmap(imageBytes: ByteArray): ImageBitmap
|
|
@ -0,0 +1,8 @@
|
|||
package net.codinux.banking.ui.service
|
||||
|
||||
import androidx.compose.ui.graphics.ImageBitmap
|
||||
import androidx.compose.ui.graphics.toComposeImageBitmap
|
||||
import org.jetbrains.skia.Image
|
||||
|
||||
actual fun createImageBitmap(imageBytes: ByteArray): ImageBitmap =
|
||||
Image.makeFromEncoded(imageBytes).toComposeImageBitmap()
|
|
@ -0,0 +1,8 @@
|
|||
package net.codinux.banking.ui.service
|
||||
|
||||
import androidx.compose.ui.graphics.ImageBitmap
|
||||
import androidx.compose.ui.graphics.toComposeImageBitmap
|
||||
import org.jetbrains.skia.Image
|
||||
|
||||
actual fun createImageBitmap(imageBytes: ByteArray): ImageBitmap =
|
||||
Image.makeFromEncoded(imageBytes).toComposeImageBitmap()
|
Loading…
Reference in New Issue