【发布时间】:2020-12-02 07:15:10
【问题描述】:
我正在尝试使用 android compose 将显示的彩色图像转换为黑白。
在视图系统中,我可以通过添加这样的过滤器将图像从彩色变为黑白
imageView.colorFilter = ColorMatrixColorFilter(ColorMatrix().apply { setSaturation(0f)})
如answer所示。
在 Android Compose 中,Image 可组合函数已经采用了颜色过滤器,但我在 compose 包中找不到 ColorMatrixColorFilter 等效项。
这是我要转换为灰度的图像代码
Image(
asset = vectorResource(id = R.drawable.xxx),
modifier = Modifier.clip(RectangleShape).size(36.dp, 26.dp),
alpha = alpha,
alignment = Alignment.Center,
contentScale = ContentScale.Fit
)
【问题讨论】:
标签: android kotlin android-jetpack-compose