Skip to content
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

Add SVG support for arbitrary data sources #4624

Closed
mipastgt opened this issue Apr 16, 2024 · 4 comments
Closed

Add SVG support for arbitrary data sources #4624

mipastgt opened this issue Apr 16, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@mipastgt
Copy link

The pull request #4605 introduced support for SVG drawables for non android platforms but there still does not seem to be an equivalent, multiplatform variant of the method
public fun loadSvgPainter(inputStream: java.io.InputStream, density: androidx.compose.ui.unit.Density): androidx.compose.ui.graphics.painter.Painter
to create an SVG painter from an arbitrary data source like, e.g., a ByteArray. Currently the support seems to be limited to resources unless I missed something.

@mipastgt mipastgt added enhancement New feature or request submitted labels Apr 16, 2024
@terrakok terrakok self-assigned this Apr 17, 2024
@terrakok
Copy link
Collaborator

terrakok commented Apr 18, 2024

Yes, we plan to add a such method to the compose core in the future. I mean the method to create a painter from a svg's ByteArray.

@gleb-skobinsky
Copy link

I just found out that you can provide a ByteArray to the new multiplatform Coil AsyncImage and it will work fine.

coil3.compose.AsyncImage(
        model = ImageRequest.Builder(LocalPlatformContext.current)
            .data(byteArray)
            .decoderFactory(SvgDecoder.Factory())
            .build(),
        modifier = modifier,
        contentDescription = null
    )

@terrakok
Copy link
Collaborator

Back to the issue: we don't have a plan to support the SVG rendering on android. It requires to have additional runtime dependency for a SVG processing on the android.
There are libraries support it already: coil or sketch or compose-imageloader

@terrakok terrakok closed this as not planned Won't fix, can't repro, duplicate, stale Jun 21, 2024
@terrakok
Copy link
Collaborator

For non-android targets there will be a method to convert a bytearray to the painter in the compose.ui module in the future though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants