From 5b4215d1d78ddacfdb67db1400484fdece7b57ed Mon Sep 17 00:00:00 2001 From: tangyuxin <462747508@qq.com> Date: Thu, 7 Dec 2017 17:13:55 +0800 Subject: [PATCH] =?UTF-8?q?[gui]=E4=BF=AE=E6=AD=A3=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E8=8E=B7=E5=8F=96=E5=9B=BE=E7=89=87=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=95=BF=E5=BA=A6=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/gui/example/gui_demo.c | 5 +++-- components/gui/example/resources.c | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/components/gui/example/gui_demo.c b/components/gui/example/gui_demo.c index fc4a361ba..901e21ff9 100644 --- a/components/gui/example/gui_demo.c +++ b/components/gui/example/gui_demo.c @@ -9,7 +9,8 @@ #include #include -extern const static unsigned char _picture_png[]; +extern const unsigned char _picture_png[]; +extern int _picture_png_length_get(void); static rt_bool_t show_demo(struct rtgui_win *win) { @@ -40,7 +41,7 @@ static rt_bool_t show_demo(struct rtgui_win *win) rtgui_rect_t draw_rect; struct rtgui_image *img; - img = rtgui_image_create_from_mem("png", _picture_png, sizeof(_picture_png), RT_TRUE); + img = rtgui_image_create_from_mem("png", _picture_png, _picture_png_length_get(), RT_TRUE); if (img != RT_NULL) { draw_rect.x1 = rect.x2 / 2 + (rect.x2 / 2 - img->w) / 2; diff --git a/components/gui/example/resources.c b/components/gui/example/resources.c index 06c0e0fca..99fd805c1 100644 --- a/components/gui/example/resources.c +++ b/components/gui/example/resources.c @@ -1,4 +1,4 @@ -const static unsigned char _picture_png[] = { +const unsigned char _picture_png[] = { 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52, 0x00,0x00,0x00,0xbe,0x00,0x00,0x00,0x4a,0x08,0x06,0x00,0x00,0x00,0x05,0x77,0xee, 0x92,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,0x00,0x00,0x0b,0x13,0x00,0x00,0x0b, @@ -1393,3 +1393,8 @@ const static unsigned char _picture_png[] = { 0x1f,0x00,0x4b,0xa8,0x7e,0x3f,0xd2,0x12,0x11,0x79,0x00,0x00,0x00,0x00,0x49,0x45, 0x4e,0x44,0xae,0x42,0x60,0x82, }; + +int _picture_png_length_get(void) +{ + return sizeof(_picture_png); +} -- GitLab