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

如何在composeResource里解码svg文件? #222

Open
kagg886 opened this issue Dec 20, 2024 · 5 comments
Open

如何在composeResource里解码svg文件? #222

kagg886 opened this issue Dec 20, 2024 · 5 comments

Comments

@kagg886
Copy link

kagg886 commented Dec 20, 2024

rt(

@panpf
Copy link
Owner

panpf commented Dec 20, 2024

使用 newComposeResourceUri() 创建专用 uri 即可,参考文档如下:

@kagg886
Copy link
Author

kagg886 commented Dec 20, 2024

目前是这样的:

rememberAsyncImagePainter(
      request = ComposableImageRequest(
            uri = Res.getUri("drawable/copy.svg")
      )
)

有没有办法可以传入DrawableResource(如Res.drawable.copy)来获取painter?Android端不支持paintResource()传入svg的方式

@panpf
Copy link
Owner

panpf commented Dec 23, 2024

uri 只能接收 String

@kagg886
Copy link
Author

kagg886 commented Dec 23, 2024

那希望可以做一个接收DrawableResource参数以返回可绘制svg的Painter(

直接填uri的话有点不太好其实

@panpf
Copy link
Owner

panpf commented Dec 23, 2024

你的主要目的是什么?由于无法访问 DrawableResource 的 ID,就拿不到图片的真实 uri,就无法在加载过程中访问原始文件流。
sketch 是要访问原始文件流才能发挥其价值,否则的话为什么不直接通过 painterResource 获取 painter 直接显示

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants