Is it possible to apply a tint to an `ImageBitmap`...
# compose
j
Is it possible to apply a tint to an
ImageBitmap
?
n
A tint is applied at draw time with an
ImageBitmap
as a parameter to the Image composable
j
I see, but in this case I’m not using the
ImageBitmap
with the
Image
Composable. I use it in an
ImageShader
. Perhaps there’s another shader I can use to apply the tint?
Copy code
@Composable
fun tiledBrush(
  @DrawableRes id: Int
): Brush = ShaderBrush(
  shader = ImageShader(
    image = ImageBitmap.imageResource(
      res = LocalContext.current.resources,
      id = id
    ),
    tileModeX = TileMode.Repeated,
    tileModeY = TileMode.Repeated
  )
)
This is the code. I’d like to apply a tint to that
ImageBitmap
as a part of this
Brush
n
Each
DrawScope.draw<x>
method accepts an optional
ColorFilter
parameter. If you just want to apply a simple tint to the call that draws this
Brush
just add
colorFilter = ColorFilter.tint(myTintColor)
ex:
drawRect(brush = tiledBrush(myDrawableResId), colorFilter = ColorFilter.tint(Color.Red)
🙏 1