From 16d8b7df41b4255cb7728d829d327334d628431a Mon Sep 17 00:00:00 2001 From: Armando Date: Mon, 30 Oct 2023 15:29:17 +0800 Subject: [PATCH] feat(color): added helper to get color space and color pixel format --- components/hal/include/hal/color_types.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/hal/include/hal/color_types.h b/components/hal/include/hal/color_types.h index e213216fb5e..5890da3f42a 100644 --- a/components/hal/include/hal/color_types.h +++ b/components/hal/include/hal/color_types.h @@ -72,8 +72,14 @@ typedef enum { /*--------------------------------------------------------------- Color Space Struct Type ---------------------------------------------------------------*/ -#define COLOR_PIXEL_FORMAT_BITWIDTH 24 ///< Bitwidth of the `color_space_format_t:pixel_format` field -#define COLOR_SPACE_BITWIDTH 8 ///< Bitwidth of the `color_space_format_t:color_space` field +///< Bitwidth of the `color_space_format_t:color_space` field +#define COLOR_SPACE_BITWIDTH 8 +///< Bitwidth of the `color_space_format_t:pixel_format` field +#define COLOR_PIXEL_FORMAT_BITWIDTH 24 +///< Helper to get `color_space_format_t:color_space` from its `color_space_pixel_format_t:color_type_id` +#define COLOR_SPACE_TYPE(color_type_id) (((color_type_id) >> COLOR_PIXEL_FORMAT_BITWIDTH) & ((1 << COLOR_SPACE_BITWIDTH) - 1)) +///< Helper to get `color_space_format_t:pixel_format` from its `color_space_pixel_format_t:color_type_id` +#define COLOR_PIXEL_FORMAT(color_type_id) ((color_type_id) & ((1 << COLOR_PIXEL_FORMAT_BITWIDTH) - 1)) /** * @brief Color Space Info Structure