feat(decoder): add svg image decoder for image widget (#7141)
Signed-off-by: zhangjipeng <zhangjipeng@xiaomi.com> Co-authored-by: zhangjipeng <zhangjipeng@xiaomi.com> Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
This commit is contained in:
18
examples/assets/img_svg_img.c
Normal file
18
examples/assets/img_svg_img.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "../../lvgl.h"
|
||||
|
||||
#if LV_BUILD_EXAMPLES
|
||||
|
||||
|
||||
const LV_ATTRIBUTE_MEM_ALIGN uint8_t img_svg_data[] = "<svg width=\"12cm\" height=\"4cm\" viewBox=\"0 0 1200 400\">"
|
||||
"<rect x=\"500\" y=\"100\" width=\"200\" height=\"200\" fill=\"red\" stroke=\"blue\" stroke-width=\"10\"/></svg>";
|
||||
|
||||
const lv_image_dsc_t img_svg_img = {
|
||||
.header.w = 450,
|
||||
.header.h = 150,
|
||||
.header.stride = 0,
|
||||
.header.cf = LV_COLOR_FORMAT_NATIVE,
|
||||
.data = img_svg_data,
|
||||
.data_size = sizeof(img_svg_data),
|
||||
};
|
||||
|
||||
#endif /* LV_BUILD_EXAMPLES */
|
||||
19
examples/widgets/image/lv_example_image_5.c
Normal file
19
examples/widgets/image/lv_example_image_5.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_IMAGE && LV_BUILD_EXAMPLES
|
||||
|
||||
void lv_example_image_5(void)
|
||||
{
|
||||
LV_IMAGE_DECLARE(img_svg_img);
|
||||
lv_obj_t * img1 = lv_image_create(lv_screen_active());
|
||||
lv_obj_set_size(img1, lv_pct(100), lv_pct(50));
|
||||
lv_obj_set_style_outline_width(img1, 5, 0);
|
||||
lv_image_set_src(img1, &img_svg_img);
|
||||
|
||||
lv_obj_set_style_transform_rotation(img1, 450, 0);
|
||||
lv_obj_set_style_transform_scale(img1, 128, 0);
|
||||
lv_image_set_scale(img1, 128);
|
||||
lv_image_set_rotation(img1, 450);
|
||||
lv_obj_align(img1, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -80,6 +80,7 @@ void lv_example_image_1(void);
|
||||
void lv_example_image_2(void);
|
||||
void lv_example_image_3(void);
|
||||
void lv_example_image_4(void);
|
||||
void lv_example_image_5(void);
|
||||
|
||||
void lv_example_imagebutton_1(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user