Hi, I'm trying to download images from web with coil3 and I achieved it in android part of my code but for iOS part I dont know how to convert Bitmaps to real files. Here is my android implementation:
@OptIn(ExperimentalCoilApi::class)
actual fun createImage(image: Image, context: PlatformContext): ByteArray? {
val bitmap = image.asDrawable(context.resources).toBitmap()
val outputStream = ByteArrayOutputStream()
bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream)
return outputStream.toByteArray()
}
in ios:
@OptIn(ExperimentalCoilApi::class)
actual fun createImage(image: Image, context: PlatformContext): ByteArray? {
val bitmap = image.toBitmap()
val pixels = bitmap.readPixels()
return pixels
}
its even looking silly I know :)). Can you share if you have any idea ? Thanks in advance.
Edit: When i tryout this, it successfully gets the image info like width and height but when i try to draw this with coil async image composable then it throws this :