Interface ColorFilter

All Superinterfaces:
RefCounted
All Known Implementing Classes:
BlendModeColorFilter, ColorMatrixColorFilter, ComposeColorFilter

public sealed interface ColorFilter extends RefCounted permits BlendModeColorFilter, ColorMatrixColorFilter, ComposeColorFilter
ColorFilters are optional objects in the drawing pipeline. When present in a paint, they are called with the "src" colors, and return new colors, which are then passed onto the next stage (either ImageFilter or Blender).

All subclasses are required to be reentrant-safe : it must be legal to share the same instance between several threads.

  • Method Details

    • isAlphaUnchanged

      default boolean isAlphaUnchanged()
      Returns the flags for this filter. Override in subclasses to return custom flags.
    • filterColor

      @ColorInt default int filterColor(@ColorInt int col)
      Applies this color filter with ARGB color, un-premultiplied.
      Parameters:
      col - base color
      Returns:
      resulting color
    • filterColor4f

      void filterColor4f(@Size(4L) float[] col, @Size(4L) float[] out, ColorSpace dstCS)
      Applies this color filter with RGBA colors. col and out store premultiplied R,G,B,A components from index 0 to 3. col and out can be the same pointer. col is read-only, out may be written multiple times.
      Parameters:
      col - base color
      out - resulting color
      dstCS - destination color space
    • compose

      @Nonnull @SharedPtr default @SharedPtr ColorFilter compose(@Nullable @SharedPtr @SharedPtr ColorFilter before)
      Returns a composed color filter that first applies the before filter and then applies this filter.
      Parameters:
      before - the filter to apply before this filter is applied, can be null
      Returns:
      a composed color filter
    • andThen

      @Nonnull @SharedPtr default @SharedPtr ColorFilter andThen(@Nullable @SharedPtr @SharedPtr ColorFilter after)
      Returns a composed color filter that first applies this filter and then applies the after filter.
      Parameters:
      after - the filter to apply after this filter is applied, can be null
      Returns:
      a composed color filter