Просмотр исходного кода

修复GUI demo图片数组名易冲突的问题

tangyuxin 8 лет назад
Родитель
Сommit
22cb22aae9
3 измененных файлов с 4 добавлено и 11 удалено
  1. 2 4
      example/gui_demo.c
  2. 1 6
      example/resources.c
  3. 1 1
      include/rtgui/rtgui_config.h

+ 2 - 4
example/gui_demo.c

@@ -8,9 +8,7 @@
 #include <rtgui/image.h>
 #include <rtgui/widgets/window.h>
 #include <rtgui/dc.h>
-
-extern const unsigned char _picture_png[];
-extern int _picture_png_length_get(void);
+#include <resources.c>
 
 static rt_bool_t show_demo(struct rtgui_win *win)
 {
@@ -41,7 +39,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, _picture_png_length_get(), RT_TRUE);
+        img = rtgui_image_create_from_mem("png", _picture_png, sizeof(_picture_png), RT_TRUE);
         if (img != RT_NULL)
         {
             draw_rect.x1 = rect.x2 / 2 + (rect.x2 / 2 - img->w) / 2;

+ 1 - 6
example/resources.c

@@ -1,4 +1,4 @@
-const unsigned char _picture_png[] = {
+static 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,8 +1393,3 @@ const 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);
-}

+ 1 - 1
include/rtgui/rtgui_config.h

@@ -67,7 +67,7 @@
 // #define GUIENGIN_USING_DESKTOP_WINDOW
 // #undef GUIENGIN_USING_SMALL_SIZE
 
-//#define GUIENGIN_USING_CALIBRATION
+// #define GUIENGIN_USING_CALIBRATION
 
 #define GUIENGIN_USING_VFRAMEBUFFER