فهرست منبع

cleanup code.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@843 bbd45198-f89e-11dd-88c7-29a3b14d5316
bernard.xiong@gmail.com 14 سال پیش
والد
کامیت
a385dc3940
2فایلهای تغییر یافته به همراه12 افزوده شده و 4 حذف شده
  1. 4 3
      examples/gui/demo_panel_single.c
  2. 8 1
      examples/gui/demo_view_image.c

+ 4 - 3
examples/gui/demo_panel_single.c

@@ -1,8 +1,9 @@
 #include <rtgui/rtgui.h>
+#include <rtgui/driver.h>
 #include <rtgui/rtgui_server.h>
 
 /*
- * a single panel for 240x320
+ * a single panel
  */
 void panel_init(void)
 {
@@ -11,8 +12,8 @@ void panel_init(void)
     /* register main panel */
     rect.x1 = 0;
     rect.y1 = 0;
-    rect.x2 = 240;
-    rect.y2 = 320;
+    rect.x2 = rtgui_graphic_driver_get_default()->width;
+    rect.y2 = rtgui_graphic_driver_get_default()->height;
     rtgui_panel_register("main", &rect);
     rtgui_panel_set_default_focused("main");
 }

+ 8 - 1
examples/gui/demo_view_image.c

@@ -36,11 +36,18 @@ static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event)
 
 		/* 设置文件路径的标签 */
 		rtgui_filelist_view_get_fullpath(view, path, sizeof(path));
-		if (image != RT_NULL) rtgui_image_destroy(image);
+		if (image != RT_NULL) 
+		{
+			rtgui_image_destroy(image);
+			image = RT_NULL;
+		}
 
 		rt_memset(image_type, 0, sizeof(image_type));
 
 		/* 获得图像的类型 */
+		if (rt_strstr(path, ".bmp") != RT_NULL ||
+			rt_strstr(path, ".BMP") != RT_NULL)
+			strcat(image_type, "bmp");
 		if (rt_strstr(path, ".png") != RT_NULL ||
 			rt_strstr(path, ".PNG") != RT_NULL)
 			strcat(image_type, "png");