Skip to content

Make BitmapFetcher available in common code#3286

Merged
colinrtwhite merged 1 commit into
coil-kt:mainfrom
dsvdmeer:dsvdmeer/multiplatform-bitmap-fetcher
Jan 15, 2026
Merged

Make BitmapFetcher available in common code#3286
colinrtwhite merged 1 commit into
coil-kt:mainfrom
dsvdmeer:dsvdmeer/multiplatform-bitmap-fetcher

Conversation

@dsvdmeer
Copy link
Copy Markdown
Contributor

In our compose multiplatform project we noticed that on iOS Coil was unable to display in-memory images (coil3.Bitmap instances) because there is no fetcher registered. On Android this does work out of the box due to the existence of a BitmapFetcher. I could see no reason why this should be implemented only for Android, and so in this PR I've moved the implementation to common code.

The Android implementation originally called data.toDrawable(options.context).asImage(), but the toDrawable(...) step in-between is basically a no-op as far as I can tell, so it should be safe to just leave that out.

Copy link
Copy Markdown
Member

@colinrtwhite colinrtwhite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea, thanks!

) : Fetcher {

override suspend fun fetch(): FetchResult {
return ImageFetchResult(
image = data.toDrawable(options.context).asImage(),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably use asImage(resources) here on Android (for automatic density scaling), however that's a separate issue. You're right data.toDrawable(options.context).asImage() is equivalent to data.asImage().

@colinrtwhite colinrtwhite enabled auto-merge (squash) January 15, 2026 20:19
@colinrtwhite colinrtwhite merged commit c2336ac into coil-kt:main Jan 15, 2026
19 of 20 checks passed
@dsvdmeer dsvdmeer deleted the dsvdmeer/multiplatform-bitmap-fetcher branch January 21, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants