-
Notifications
You must be signed in to change notification settings - Fork 676
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attempt to execute image request in Android Studio previews. (#2329)
* Attempt to execute image request in Android Studio previews. * Fix tests. * Inline. * Rework API. * Spotless.
- Loading branch information
1 parent
6ada1f8
commit 33ea5bc
Showing
12 changed files
with
149 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
coil-compose-core/src/androidMain/kotlin/coil3/compose/ImagePainter.android.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,32 @@ | ||
package coil3.compose | ||
|
||
import androidx.compose.ui.graphics.Canvas | ||
import androidx.compose.ui.graphics.FilterQuality | ||
import androidx.compose.ui.graphics.asImageBitmap | ||
import androidx.compose.ui.graphics.nativeCanvas | ||
import androidx.compose.ui.graphics.painter.BitmapPainter | ||
import androidx.compose.ui.graphics.painter.Painter | ||
import coil3.BitmapImage | ||
import coil3.DrawableImage | ||
import coil3.Image | ||
import coil3.PlatformContext | ||
import coil3.annotation.ExperimentalCoilApi | ||
import coil3.asDrawable | ||
import com.google.accompanist.drawablepainter.DrawablePainter | ||
|
||
@ExperimentalCoilApi | ||
actual fun Image.asPainter( | ||
context: PlatformContext, | ||
filterQuality: FilterQuality, | ||
): Painter = when (this) { | ||
is BitmapImage -> BitmapPainter( | ||
image = bitmap.asImageBitmap(), | ||
filterQuality = filterQuality, | ||
) | ||
is DrawableImage -> DrawablePainter( | ||
drawable = asDrawable(context.resources).mutate(), | ||
) | ||
else -> ImagePainter(this) | ||
} | ||
|
||
internal actual val Canvas.nativeCanvas get() = nativeCanvas |
Oops, something went wrong.