Skip to content

Commit

Permalink
feat(draw/sw): added support for LV_COLOR_FORMAT_L8 (lvgl#5800)
Browse files Browse the repository at this point in the history
Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com>
Signed-off-by: qinshijing <qinshijing@xiaomi.com>
Co-authored-by: Zoltan Janosy <zjanosy@fishman.com>
Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
Co-authored-by: VIFEX <vifextech@foxmail.com>
Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
Co-authored-by: Niklas Fiekas <niklas.fiekas@sartorius.com>
Co-authored-by: qinshijing <51692568+qinshijing@users.noreply.github.com>
Co-authored-by: qinshijing <qinshijing@xiaomi.com>
Co-authored-by: Neo Xu <neo.xu1990@gmail.com>
  • Loading branch information
9 people authored Apr 20, 2024
1 parent be4a9d1 commit abc8a72
Show file tree
Hide file tree
Showing 114 changed files with 3,033 additions and 83 deletions.
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ repos:
exclude: |
(?x)^(
src/libs/ |
src/lv_conf_internal.h
src/lv_conf_internal.h |
tests/test_images
)
types_or: ["c", "header"]
- repo: https://github.com/crate-ci/typos
Expand Down
67 changes: 67 additions & 0 deletions demos/render/assets/img_render_lvgl_logo_l8.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#ifdef __has_include
#if __has_include("lvgl.h")
#ifndef LV_LVGL_H_INCLUDE_SIMPLE
#define LV_LVGL_H_INCLUDE_SIMPLE
#endif
#endif
#endif

#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
#include "lvgl.h"
#else
#include "lvgl/lvgl.h"
#endif


#ifndef LV_ATTRIBUTE_MEM_ALIGN
#define LV_ATTRIBUTE_MEM_ALIGN
#endif

#ifndef LV_ATTRIBUTE_IMG_IMG_RENDER_LVGL_LOGO_L8
#define LV_ATTRIBUTE_IMG_IMG_RENDER_LVGL_LOGO_L8
#endif

const LV_ATTRIB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x6a,0x6a,0x6a,0x6a,0x6a,0x6a,0x6a,0xe9,0xcb,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0xea,
0xd2,0x6a,0x6a,0x6a,0x6a,0x6a,0x6a,0x6a,0x6a,0xe9,0xd2,0x6a,0x6a,0x6a,0x6a,0x6a,0x6a,0x6a,0x6a,0xe9,0xcb,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x64,0xfd,
0xd7,0x6a,0x6a,0x6a,0x6a,0x6a,0x6a,0x6a,0x6a,0xf2,0xd7,0x6a,0x6a,0x6a,0x6a,0x6a,0x6a,0x6a,0x6a,0xf2,0xdc,0x1d,0x1d,0x1d,0x1d,0x1d,0x1d,0x56,0xe1,0xfd,
0xfd,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xee,0xfd,0xfd,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xee,0xfd,0xfd,0xed,0xe6,0xe6,0xe6,0xe6,0xe6,0xfa,0xfd,0xfd,

};

const lv_image_dsc_t img_render_lvgl_logo_l8 = {
.header.cf = LV_COLOR_FORMAT_L8,
.header.w = 30,
.header.h = 30,
.data = img_render_lvgl_logo_l8_map,
.data_size = sizeof(img_render_lvgl_logo_l8_map),
};

Binary file added demos/render/assets/img_render_lvgl_logo_l8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 35 additions & 17 deletions demos/render/lv_demo_render.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* @file lv_demo_render.c
*
*/
Expand Down Expand Up @@ -329,79 +329,95 @@ static lv_obj_t * image_obj_create(lv_obj_t * parent, int32_t col, int32_t row,

}

static void image_core_cb(lv_obj_t * parent, bool recolor)
static void image_core_cb(lv_obj_t * parent, bool recolor, uint32_t startAt)
{
LV_IMAGE_DECLARE(img_render_lvgl_logo_xrgb8888);
LV_IMAGE_DECLARE(img_render_lvgl_logo_rgb888);
LV_IMAGE_DECLARE(img_render_lvgl_logo_rgb565);
LV_IMAGE_DECLARE(img_render_lvgl_logo_argb8888);
LV_IMAGE_DECLARE(img_render_lvgl_logo_l8);

const void * srcs[] = {
&img_render_lvgl_logo_argb8888,
&img_render_lvgl_logo_xrgb8888,
&img_render_lvgl_logo_rgb888,
&img_render_lvgl_logo_rgb565,
&img_render_lvgl_logo_l8,
};

const void * names[] = {
"ARGB\n8888",
"XRGB\n8888",
"RGB\n888",
"RGB\n565",
"L8",
};

uint32_t stopAt = startAt + LV_MIN(sizeof(srcs) / sizeof(void *) - startAt, 4);
uint32_t i;
for(i = 0; i < 4; i++) {
for(i = startAt; i < stopAt; i++) {
lv_obj_t * obj;
uint32_t row = i - startAt;

obj = lv_label_create(parent);
lv_label_set_text(obj, names[i]);
add_to_cell(obj, 0, i * 2);
add_to_cell(obj, 0, row * 2);

obj = image_obj_create(parent, 1, i * 2, recolor);
obj = image_obj_create(parent, 1, row * 2, recolor);
lv_image_set_src(obj, srcs[i]);

obj = image_obj_create(parent, 2, i * 2, recolor);
obj = image_obj_create(parent, 2, row * 2, recolor);
lv_image_set_src(obj, srcs[i]);
lv_image_set_rotation(obj, 300);
lv_image_set_pivot(obj, 0, 0);

obj = image_obj_create(parent, 3, i * 2, recolor);
obj = image_obj_create(parent, 3, row * 2, recolor);
lv_image_set_src(obj, srcs[i]);
lv_image_set_scale(obj, 400);
lv_image_set_pivot(obj, 0, 0);

obj = image_obj_create(parent, 4, i * 2, recolor);
obj = image_obj_create(parent, 4, row * 2, recolor);
lv_image_set_src(obj, srcs[i]);
lv_image_set_scale_x(obj, 400);
lv_image_set_pivot(obj, 0, 0);

obj = image_obj_create(parent, 5, i * 2, recolor);
obj = image_obj_create(parent, 5, row * 2, recolor);
lv_image_set_src(obj, srcs[i]);
lv_image_set_scale_y(obj, 400);
lv_image_set_pivot(obj, 0, 0);

obj = image_obj_create(parent, 6, i * 2, recolor);
obj = image_obj_create(parent, 6, row * 2, recolor);
lv_image_set_src(obj, srcs[i]);
lv_image_set_rotation(obj, 300);
lv_image_set_scale(obj, 400);
lv_image_set_pivot(obj, 0, 0);

obj = image_obj_create(parent, 7, i * 2, recolor);
obj = image_obj_create(parent, 7, row * 2, recolor);
lv_image_set_src(obj, srcs[i]);
lv_image_set_scale_y(obj, 400);
lv_image_set_rotation(obj, 300);
lv_image_set_pivot(obj, 0, 0);
}
}

static void image_normal_cb(lv_obj_t * parent)
static void image_normal_1_cb(lv_obj_t * parent)
{
image_core_cb(parent, false, 0);
}

static void image_recolored_1_cb(lv_obj_t * parent)
{
image_core_cb(parent, true, 0);
}

static void image_normal_2_cb(lv_obj_t * parent)
{
image_core_cb(parent, false);
image_core_cb(parent, false, 4);
}

static void image_recolored_cb(lv_obj_t * parent)
static void image_recolored_2_cb(lv_obj_t * parent)
{
image_core_cb(parent, true);
image_core_cb(parent, true, 4);
}

static lv_obj_t * line_obj_create(lv_obj_t * parent, int32_t col, int32_t row, lv_point_precise_t p[])
Expand Down Expand Up @@ -827,8 +843,10 @@ static scene_dsc_t scenes[] = {
{.name = "border", .create_cb = border_cb},
{.name = "box_shadow", .create_cb = box_shadow_cb},
{.name = "text", .create_cb = text_cb},
{.name = "image_normal", .create_cb = image_normal_cb},
{.name = "image_recolor", .create_cb = image_recolored_cb},
{.name = "image_normal_1", .create_cb = image_normal_1_cb},
{.name = "image_recolor_1", .create_cb = image_recolored_1_cb},
{.name = "image_normal_2", .create_cb = image_normal_2_cb},
{.name = "image_recolor_2", .create_cb = image_recolored_2_cb},
{.name = "line", .create_cb = line_cb},
{.name = "arc_normal", .create_cb = arc_normal_cb},
{.name = "arc_image", .create_cb = arc_image_cb},
Expand Down
8 changes: 5 additions & 3 deletions demos/render/lv_demo_render.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* @file lv_demo_render.h
*
*/
Expand Down Expand Up @@ -33,8 +33,10 @@ typedef enum {
LV_DEMO_RENDER_SCENE_BORDER,
LV_DEMO_RENDER_SCENE_BOX_SHADOW,
LV_DEMO_RENDER_SCENE_TEXT,
LV_DEMO_RENDER_SCENE_IMAGE_NORMAL,
LV_DEMO_RENDER_SCENE_IMAGE_RECOLOR,
LV_DEMO_RENDER_SCENE_IMAGE_NORMAL_1,
LV_DEMO_RENDER_SCENE_IMAGE_RECOLOR_1,
LV_DEMO_RENDER_SCENE_IMAGE_NORMAL_2,
LV_DEMO_RENDER_SCENE_IMAGE_RECOLOR_2,
LV_DEMO_RENDER_SCENE_LINE,
LV_DEMO_RENDER_SCENE_ARC_NORMAL,
LV_DEMO_RENDER_SCENE_ARC_IMAGE,
Expand Down
Loading

0 comments on commit abc8a72

Please sign in to comment.