Is there any multiplatform class in stdlib or some...
# multiplatform
e
Is there any multiplatform class in stdlib or some library which can manipulate with images?
m
What kind of manipulations do you have in mind?
e
I have a ByteArray and need some function like Android’s
Bitmap.getPixels
.
m
If you are using this in conjunction with Compose you can use functions like this:
Copy code
Image.makeFromEncoded(encodedImageData).toComposeImageBitmap()
SKIA provides such import/export functions for images.
e
@Michael Paus Do you know why I am getting an error with this line:
Copy code
val bitmap: ImageBitmap = remember { org.jetbrains.skia.Image.makeFromEncoded(image).toComposeImageBitmap() }
I get
Unresolved reference: toComposeImageBitmap
during the build process, while IDE doesn’t show errors. I am using in in the compose shared module. Targeting Android.
m
For Android you have to use
Copy code
BitmapFactory.decodeByteArray(encodedImageData, 0, encodedImageData.size).asImageBitmap()
because we don’t have Skia access on Android.
e
hmm, so I can’t make compose multiplatform code with
Image
showing image from a
ByteArray
without using expect/actual converter function?
👌 2
Thank you a lot!
m
I just answered the exact same question here just a few minutes ago 😉: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1705255315788899
e
I didn’t realise that it was the same topic, thank you! It is a bit weird that IDE doesn’t show any errors here
Otherwise it will be more clear what direction one should investigate
m
Yes, that is weird but I got used to it because that happens so often 🤨.
👍 1
e
@Michael Paus Do you by any chance know any simple solution to make
Image
show the image rotated corresponding to its EXIF? Do I have to read Exif and manually rotate it or is there any build-in mechanism?
m
You probably have to do the rotation yourself via a rotation transform but you can easily read the flag via https://github.com/Ashampoo/kim
👍 1