Thread
#compose
    j

    julioromano

    1 year ago
    Is it possible to apply a tint to an
    ImageBitmap
    ?
    Nader Jawad

    Nader Jawad

    1 year ago
    A tint is applied at draw time with an
    ImageBitmap
    as a parameter to the Image composable
    j

    julioromano

    1 year ago
    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?
    @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
    Nader Jawad

    Nader Jawad

    1 year ago
    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)