Esempio n. 1
0
static int xml_load_items(const char* filename)
{    
    struct rtgui_filerw* filerw;
    char buffer[512];
    rtgui_xml_t *xml;
    int length;

    /* create filerw context */
    filerw = rtgui_filerw_create_file(filename, "rb");
    if (filerw == RT_NULL) 
    {
        rt_kprintf("read file fail %s\n", filename);
        return 0;
    }

    length = rtgui_filerw_read(filerw, buffer, 512, 1);
    if(length <= 0)
    {
        rt_kprintf("read fail\n");
        rtgui_filerw_close(filerw);        
        return 0;
    }
    
    xml = rtgui_xml_create(512, xml_event_handler, RT_NULL);
    if (xml != RT_NULL)    
    {        
        rtgui_xml_parse(xml, buffer, length);
        rtgui_xml_destroy(xml);    
    }

    rtgui_filerw_close(filerw);        
    return 0;
}
Esempio n. 2
0
void load_img_test(char *fname)
{
	struct rtgui_filerw *filerw;
	struct rtgui_image image;
	struct rtgui_rect rect;
	struct rtgui_dc_hw *dc;
	struct rtgui_image_engine *img_eng;

	printf_syn("fun:%s, line:%d, fn:%s\n", __FUNCTION__, __LINE__, fname);

	filerw = rtgui_filerw_create_file(fname, "rb");
	if (NULL == filerw) {
		printf_syn("fun:%s, line:%d, fn:%s\n", __FUNCTION__, __LINE__, fname);
		return;
	}

	img_eng = &rtgui_image_hdc_engine;

	if (RT_TRUE != img_eng->image_check(filerw)) {
		printf_syn("fun:%s, line:%d\n", __FUNCTION__, __LINE__);
		return;
	}

	if (RT_TRUE != img_eng->image_load(&image, filerw, RT_FALSE)) {
		printf_syn("fun:%s, line:%d\n", __FUNCTION__, __LINE__);
		return;
	}

	dc = (struct rtgui_dc_hw*) rtgui_malloc(sizeof(struct rtgui_dc_hw));
	dc->parent.type = RTGUI_DC_HW;
	dc->parent.engine = &dc_hw_engine;
	dc->owner = NULL;
	dc->hw_driver = rtgui_graphic_driver_get_default();

	rect.x1 = 0;
	rect.y1 = 0;
	rect.x2 = rtgui_graphic_driver_get_default()->width;
	rect.y2 = rtgui_graphic_driver_get_default()->height;
	printf_syn("fun:%s, line:%d, 0x%x\n", __FUNCTION__, __LINE__, img_eng->image_blit);
	img_eng->image_blit(&image, (struct rtgui_dc*)dc, &rect);

	rt_thread_delay(get_ticks_of_ms(5000));
	printf_syn("fun:%s, line:%d, fn:%s\n", __FUNCTION__, __LINE__, fname);

	img_eng->image_unload(&image);
	printf_syn("fun:%s, line:%d, fn:%s\n", __FUNCTION__, __LINE__, fname);

	//rect.x1 = rtgui_filerw_close(filerw); /* unload 已close */

	printf_syn("fun:%s, line:%d, ret:%d, fn:%s\n", __FUNCTION__, __LINE__, rect.x1, fname);

	rtgui_free(dc);
	return;
}