# lv_color_op.h (/api/misc/lv_color_op_h)



<RelatedHeaders name="lv_color_op_private.h" isPrivate="false" />

<ApiSummary functions="6" structs="1" typedefs="1" />

Functions [#functions]

<ApiMember kind="function" name="lv_color_mix" file="misc/lv_color_op.h" line="49" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_color_op.h#L49">
  lv_color_mix [#lv_color_mix]

  Mix two colors with a given ratio.

  ```c title=" " lineNumbers=1
  lv_color_t lv_color_mix(lv_color_t c1, lv_color_t c2, uint8_t mix)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name  | Type                          | Description                                                                        |
  | ----- | ----------------------------- | ---------------------------------------------------------------------------------- |
  | `c1`  | <ApiLink name="lv_color_t" /> | the first color to mix (usually the foreground)                                    |
  | `c2`  | <ApiLink name="lv_color_t" /> | the second color to mix (usually the background)                                   |
  | `mix` | <ApiLink name="uint8_t" />    | The ratio of the colors. 0: full `c2`, 255: full `c1`, 127: half `c1` and half`c2` |

  **Returns:** <ApiLink name="lv_color_t" /> — the mixed color
</ApiMember>

<ApiMember kind="function" name="lv_color_mix32" file="misc/lv_color_op.h" line="59" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_color_op.h#L59">
  lv_color_mix32 [#lv_color_mix32]

  ```c title=" " lineNumbers=1
  lv_color32_t lv_color_mix32(lv_color32_t fg, lv_color32_t bg)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name | Type                            |
  | ---- | ------------------------------- |
  | `fg` | <ApiLink name="lv_color32_t" /> |
  | `bg` | <ApiLink name="lv_color32_t" /> |

  <Callout type="info">
    Use bg.alpha in the return value
  </Callout>

  <Callout type="info">
    Use fg.alpha as mix ratio
  </Callout>
</ApiMember>

<ApiMember kind="function" name="lv_color_mix32_premultiplied" file="misc/lv_color_op.h" line="74" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_color_op.h#L74">
  lv_color_mix32_premultiplied [#lv_color_mix32_premultiplied]

  Blends two premultiplied ARGB8888 colors while maintaining correct alpha compositing.

  This function correctly blends the foreground (fg) and background (bg) colors, ensuring that the output remains in a premultiplied alpha format.

  ```c title=" " lineNumbers=1
  lv_color32_t lv_color_mix32_premultiplied(lv_color32_t fg, lv_color32_t bg)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name | Type                            | Description                                            |
  | ---- | ------------------------------- | ------------------------------------------------------ |
  | `fg` | <ApiLink name="lv_color32_t" /> | The foreground color in premultiplied ARGB8888 format. |
  | `bg` | <ApiLink name="lv_color32_t" /> | The background color in premultiplied ARGB8888 format. |

  **Returns:** <ApiLink name="lv_color32_t" /> — The resulting blended color in premultiplied ARGB8888 format.

  <Callout type="info">
    If the foreground is fully opaque, it is returned as is.
  </Callout>

  <Callout type="info">
    If the foreground is fully transparent, the background is returned.
  </Callout>
</ApiMember>

<ApiMember kind="function" name="lv_color_brightness" file="misc/lv_color_op.h" line="81" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_color_op.h#L81">
  lv_color_brightness [#lv_color_brightness]

  Get the brightness of a color

  ```c title=" " lineNumbers=1
  uint8_t lv_color_brightness(lv_color_t c)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name | Type                          | Description |
  | ---- | ----------------------------- | ----------- |
  | `c`  | <ApiLink name="lv_color_t" /> | a color     |

  **Returns:** <ApiLink name="uint8_t" /> — brightness in range \[0..255]
</ApiMember>

<ApiMember kind="function" name="lv_color_filter_dsc_init" file="misc/lv_color_op.h" line="83" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_color_op.h#L83">
  lv_color_filter_dsc_init [#lv_color_filter_dsc_init]

  ```c title=" " lineNumbers=1
  void lv_color_filter_dsc_init(lv_color_filter_dsc_t *dsc, lv_color_filter_cb_t cb)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name  | Type                                                                       |
  | ----- | -------------------------------------------------------------------------- |
  | `dsc` | <ApiLink name="lv_color_filter_dsc_t" display="lv_color_filter_dsc_t *" /> |
  | `cb`  | <ApiLink name="lv_color_filter_cb_t" />                                    |
</ApiMember>

<ApiMember kind="function" name="lv_color_over32" file="misc/lv_color_op.h" line="91" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_color_op.h#L91">
  lv_color_over32 [#lv_color_over32]

  Blend two colors that have not been pre-multiplied using their alpha values

  ```c title=" " lineNumbers=1
  lv_color32_t lv_color_over32(lv_color32_t fg, lv_color32_t bg)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name | Type                            | Description          |
  | ---- | ------------------------------- | -------------------- |
  | `fg` | <ApiLink name="lv_color32_t" /> | the foreground color |
  | `bg` | <ApiLink name="lv_color32_t" /> | the background color |

  **Returns:** <ApiLink name="lv_color32_t" /> — result color
</ApiMember>

Structs [#structs]

<ApiMember kind="struct" name="_lv_color_filter_dsc_t">
  \_lv_color_filter_dsc_t [#_lv_color_filter_dsc_t]

  | Member      | Type                                    | Description |
  | ----------- | --------------------------------------- | ----------- |
  | `filter_cb` | <ApiLink name="lv_color_filter_cb_t" /> |             |
  | `user_data` | `void *`                                |             |
</ApiMember>

Typedefs [#typedefs]

<ApiMember kind="typedef" name="lv_color_filter_cb_t" file="misc/lv_color_op.h" line="31" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_color_op.h#L31">
  lv_color_filter_cb_t [#lv_color_filter_cb_t]

  ```c title=" " lineNumbers=1
  typedef lv_color_t(* lv_color_filter_cb_t) (const struct _lv_color_filter_dsc_t *, lv_color_t, lv_opa_t)
  ```
</ApiMember>

<TypeUsedBy name="lv_color_filter_cb_t" count="1">
  * `lv_color_filter_dsc_init` — param `cb`
</TypeUsedBy>

Dependencies [#dependencies]

<FileIncludes includes="[&#x22;lv_assert.h&#x22;, &#x22;lv_math.h&#x22;, &#x22;lv_color.h&#x22;, &#x22;lv_types.h&#x22;]" includedBy="[&#x22;lv_global.h&#x22;, &#x22;lv_color.h&#x22;, &#x22;lv_color_op_private.h&#x22;]" transitiveIncludes="[&#x22;lv_conf_internal.h&#x22;, &#x22;lv_conf_kconfig.h&#x22;, &#x22;lv_log.h&#x22;, &#x22;lv_mem.h&#x22;, &#x22;lv_palette.h&#x22;, &#x22;lv_string.h&#x22;]" />
