RemoteImageSample
@Sampled
@Preview
@PreviewWrapper(RemoteComponentPreviewWrapper::class)
@Composable
fun RemoteImageSample() {
val remoteBitmap = remember {
val imageBitmap = ImageBitmap(120, 60)
Canvas(imageBitmap).apply {
drawRect(0f, 0f, 120f, 60f, Paint().apply { color = Color(0xFF1E88E5) })
drawCircle(Offset(60f, 30f), 20f, Paint().apply { color = Color(0xFFFFCA28) })
}
RemoteImageBitmap(imageBitmap)
}
RemoteImage(
bitmap = remoteBitmap,
contentDescription = "Sample Remote Image".rs,
modifier = RemoteModifier.size(100.rdp),
contentScale = RemoteContentScale.Crop,
)
}
RemoteImageFitSample
@Sampled
@Preview
@PreviewWrapper(RemoteComponentPreviewWrapper::class)
@Composable
fun RemoteImageFitSample() {
val remoteBitmap = remember {
val imageBitmap = ImageBitmap(120, 60)
Canvas(imageBitmap).apply {
drawRect(0f, 0f, 120f, 60f, Paint().apply { color = Color(0xFF1E88E5) })
drawCircle(Offset(60f, 30f), 20f, Paint().apply { color = Color(0xFFFFCA28) })
}
RemoteImageBitmap(imageBitmap)
}
RemoteImage(
bitmap = remoteBitmap,
contentDescription = "Fit Sample".rs,
modifier = RemoteModifier.size(100.rdp).background(Color.LightGray.rc),
contentScale = RemoteContentScale.Fit,
)
}