-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert base64 text to images/gifs #960
Conversation
…H and theres no spaces and new lines
It still freezes the app if i press the show more button. Should I try to change the text note to make it convert the base64 to a image? |
I think we will have to :( |
} | ||
|
||
val imageBytes = runCatching { Base64.decode(base64String2, Base64.DEFAULT) }.getOrNull() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also use the Base64 Requester which I think does the decoding in an IO thread.
val context = LocalContext.current
val base64Painter =
rememberAsyncImagePainter(
model = Base64Requester.imageRequest(context, model),
)
Image(
painter = base64Painter,
contentDescription = contentDescription,
modifier = modifier,
alignment = alignment,
contentScale = contentScale,
colorFilter = colorFilter,
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using this makes base64 gifs not work
commons/src/main/java/com/vitorpamplona/amethyst/commons/richtext/RichTextParser.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please @greenart7c3 can you try this solution?(It's a slight modification of @vitorpamplona 's suggestion. Needs Coil's gif library extension, see here.
Edit: moved LocalContext call to the top, for correctness.
val context = LocalContext.current
val gifImageLoader = ImageLoader.Builder(context)
.components {
if (SDK_INT >= 28) {
add(ImageDecoderDecoder.Factory())
} else {
add(GifDecoder.Factory())
}
}
.build()
val base64Painter =
rememberAsyncImagePainter(
model = Base64Requester.imageRequest(context, model),
imageLoader = gifImageLoader
)
Image(
painter = base64Painter,
contentDescription = contentDescription,
modifier = modifier,
alignment = alignment,
contentScale = contentScale,
colorFilter = colorFilter,
)
Thanks, I'll test this tomorrow morning |
Gifs doesn't animate when I use this solution |
Thanks for the feedback. I guess the problem is at the level of Coil then. |
Trying this pull request. How is this functionality invoked from the app please? Edit: never mind, found the associated bug! |
Very slow scrolling of home feed on first try. Is this a known issue or just cache priming? |
I'll look at this later. Have you tried creating a release build to see if it's slow too? |
It was a debug build... And trying other branches with a debug build it's similarly slow. So I suspect it's the debug build rather than your PR 👍 |
Yeah, debug will always be extremely slow due to the added tracking points for debug. Use the "benchmark" build variant to see real speeds. |
Good point, thanks! |
fixes #951