qdsfdhvh / compose-imageloader

Compose Image library for Kotlin Multiplatform.
https://qdsfdhvh.github.io/compose-imageloader/
MIT License
419 stars 16 forks source link

加载图片报错 #104

Closed WngYilei closed 1 year ago

WngYilei commented 1 year ago

version: api("io.github.qdsfdhvh:image-loader:1.2.10") kotlin version : 1.8.0 Compose : 1.3.0

image

Ktor 请求日志:

log----start------- I/System.out: REQUEST: https://www.wanandroid.com/blogimgs/42da12d8-de56-4439-b40c-eab66c227a4b.png I/System.out: METHOD: HttpMethod(value=GET) I/System.out: COMMON HEADERS I/System.out: -> Accept: application/json I/System.out: -> Accept-Charset: UTF-8 I/System.out: CONTENT HEADERS I/System.out: -> Content-Length: 0 I/System.out: RESPONSE: 200 OK I/System.out: METHOD: HttpMethod(value=GET) I/System.out: FROM: https://www.wanandroid.com/blogimgs/42da12d8-de56-4439-b40c-eab66c227a4b.png I/System.out: COMMON HEADERS I/System.out: -> accept-ranges: bytes I/System.out: -> cache-control: private I/System.out: -> content-length: 80542 I/System.out: -> content-type: image/png I/System.out: -> date: Sun, 26 Mar 2023 06:41:36 GMT I/System.out: -> etag: W/"80542-1647681580000" I/System.out: -> expires: Thu, 01 Jan 1970 08:00:00 CST I/System.out: -> last-modified: Sat, 19 Mar 2022 09:19:40 GMT I/System.out: -> server: Apache-Coyote/1.1 I/System.out: status:Failure(error=java.lang.RuntimeException: Unable to create a decoder that supports: Source(request=com.seiko.imageloader.model.ImageRequest@b719312, source=buffer(source(io.ktor.utils.io.jvm.javaio.InputAdapter@c174ae3)), dataSource=Engine, extra={KEY_MIME_TYPE=image/png}))

log-----end-------

Failure(error=java.lang.RuntimeException: Unable to create a decoder that supports: Source(request=com.seiko.imageloader.model.ImageRequest@b719312, source=buffer(source(io.ktor.utils.io.jvm.javaio.InputAdapter@c174ae3)), dataSource=Engine, extra={KEY_MIME_TYPE=image/png}))

我把painter 的请求状态 打印出来了,打印报错 就是上面提示的错误。 要解决这个错误 需要从哪里入手啊,麻烦大佬给提供个思路

qdsfdhvh commented 1 year ago

需要额外在components{}中添加 add(BitmapFactoryDecoder.Factory(applicationContext, 4096))(android) or add(SkiaImageDecoder.Factory())(skia),setupKtorComponents()里面只下载了图片,没有解码,所以显示不出来。

WngYilei commented 1 year ago

ok , 感谢大佬解答,我试试