Failed to Image::makeFromEncoded
DatL4g opened this issue · comments
Loading some image URLs fail on Desktop JVM. (Not tested on Android)
Exception: Failed to Image::makeFromEncoded
Example URL: https://img-cdn.hltv.org/teamlogo/6LVaK1MVX06kO1ChAq22v6.svg?ixlib=java-2.1.0&s=1ad0be7366aab3ef6825996762c3e615
My KamelConfig:
KamelConfig {
takeFrom(KamelConfig.Default)
resourcesFetcher()
svgDecoder()
imageVectorDecoder()
}
Example Image display:
KamelImage(
resource = asyncPainterResource("https://img-cdn.hltv.org/teamlogo/6LVaK1MVX06kO1ChAq22v6.svg?ixlib=java-2.1.0&s=1ad0be7366aab3ef6825996762c3e615"),
contentDescription = null
)
that's a svg. And the only way the library currently detects svgs is having a .svg
extension. If you add .svg
to the url: https://img-cdn.hltv.org/teamlogo/6LVaK1MVX06kO1ChAq22v6.svg?ixlib=java-2.1.0&s=1ad0be7366aab3ef6825996762c3e615.url
it will work... kinda... I just tried and unfortunately there's an issue rendering it:
svg's are not working on android yet fyi. So that definitely won't work
The URL already contains .svg
as ending, so it should detect it.
I guess it doesn't because of the query parameter.
Yeah it would have to end in .svg
not contain it atm.
This is the issue.
when (data.toString().substringAfterLast(".")) {
"svg" -> kamelConfig.loadSvgResource(data, resourceConfig)
"xml" -> kamelConfig.loadImageVectorResource(data, resourceConfig)
else -> kamelConfig.loadImageBitmapResource(data, resourceConfig)
}
Yeah I think it should parse this as a Uri or Url and just take the path and then check the ending.
As fallback (when it can't be parsed) the existing method would be fine I guess
released in v0.6.0
Thanks again!