mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-22 03:09:16 +08:00
update image container.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1255 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
@@ -1,77 +1,76 @@
|
||||
/*
|
||||
* File : image.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2009-10-16 Bernard first version
|
||||
*/
|
||||
#ifndef __RTGUI_IMAGE_H__
|
||||
#define __RTGUI_IMAGE_H__
|
||||
|
||||
#include <rtgui/dc.h>
|
||||
#include <rtgui/filerw.h>
|
||||
#include <rtgui/region.h>
|
||||
|
||||
struct rtgui_image;
|
||||
struct rtgui_image_engine
|
||||
{
|
||||
const char* name;
|
||||
struct rtgui_list_node list;
|
||||
|
||||
/* image engine function */
|
||||
rt_bool_t (*image_check)(struct rtgui_filerw* file);
|
||||
|
||||
rt_bool_t (*image_load)(struct rtgui_image* image, struct rtgui_filerw* file, rt_bool_t load);
|
||||
void (*image_unload)(struct rtgui_image* image);
|
||||
|
||||
void (*image_blit)(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* rect);
|
||||
};
|
||||
|
||||
struct rtgui_image_palette
|
||||
{
|
||||
rtgui_color_t* colors;
|
||||
rt_uint32_t ncolors;
|
||||
};
|
||||
typedef struct rtgui_image_palette rtgui_image_palette_t;
|
||||
|
||||
struct rtgui_image
|
||||
{
|
||||
/* image metrics */
|
||||
rt_uint16_t w, h;
|
||||
|
||||
/* image engine */
|
||||
const struct rtgui_image_engine* engine;
|
||||
|
||||
/* image palette */
|
||||
rtgui_image_palette_t* palette;
|
||||
|
||||
/* image private data */
|
||||
void* data;
|
||||
};
|
||||
typedef struct rtgui_image rtgui_image_t;
|
||||
|
||||
/* init rtgui image system */
|
||||
void rtgui_system_image_init(void);
|
||||
|
||||
#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
|
||||
struct rtgui_image* rtgui_image_create_from_file(const char* type, const char* filename, rt_bool_t load);
|
||||
struct rtgui_image* rtgui_image_create(const char* filename, rt_bool_t load);
|
||||
#endif
|
||||
struct rtgui_image* rtgui_image_create_from_mem(const char* type, const rt_uint8_t* data, rt_size_t length, rt_bool_t load);
|
||||
void rtgui_image_destroy(struct rtgui_image* image);
|
||||
|
||||
/* register an image engine */
|
||||
void rtgui_image_register_engine(struct rtgui_image_engine* engine);
|
||||
|
||||
/* blit an image on DC */
|
||||
void rtgui_image_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* rect);
|
||||
struct rtgui_image_palette* rtgui_image_palette_create(rt_uint32_t ncolors);
|
||||
|
||||
|
||||
#endif
|
||||
/*
|
||||
* File : image.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2009-10-16 Bernard first version
|
||||
*/
|
||||
#ifndef __RTGUI_IMAGE_H__
|
||||
#define __RTGUI_IMAGE_H__
|
||||
|
||||
#include <rtgui/dc.h>
|
||||
#include <rtgui/filerw.h>
|
||||
#include <rtgui/region.h>
|
||||
|
||||
struct rtgui_image;
|
||||
struct rtgui_image_engine
|
||||
{
|
||||
const char* name;
|
||||
struct rtgui_list_node list;
|
||||
|
||||
/* image engine function */
|
||||
rt_bool_t (*image_check)(struct rtgui_filerw* file);
|
||||
|
||||
rt_bool_t (*image_load)(struct rtgui_image* image, struct rtgui_filerw* file, rt_bool_t load);
|
||||
void (*image_unload)(struct rtgui_image* image);
|
||||
|
||||
void (*image_blit)(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* rect);
|
||||
};
|
||||
|
||||
struct rtgui_image_palette
|
||||
{
|
||||
rtgui_color_t* colors;
|
||||
rt_uint32_t ncolors;
|
||||
};
|
||||
typedef struct rtgui_image_palette rtgui_image_palette_t;
|
||||
|
||||
struct rtgui_image
|
||||
{
|
||||
/* image metrics */
|
||||
rt_uint16_t w, h;
|
||||
|
||||
/* image engine */
|
||||
const struct rtgui_image_engine* engine;
|
||||
|
||||
/* image palette */
|
||||
rtgui_image_palette_t* palette;
|
||||
|
||||
/* image private data */
|
||||
void* data;
|
||||
};
|
||||
typedef struct rtgui_image rtgui_image_t;
|
||||
|
||||
/* init rtgui image system */
|
||||
void rtgui_system_image_init(void);
|
||||
|
||||
#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
|
||||
struct rtgui_image* rtgui_image_create_from_file(const char* type, const char* filename, rt_bool_t load);
|
||||
struct rtgui_image* rtgui_image_create(const char* filename, rt_bool_t load);
|
||||
#endif
|
||||
struct rtgui_image* rtgui_image_create_from_mem(const char* type, const rt_uint8_t* data, rt_size_t length, rt_bool_t load);
|
||||
void rtgui_image_destroy(struct rtgui_image* image);
|
||||
|
||||
/* register an image engine */
|
||||
void rtgui_image_register_engine(struct rtgui_image_engine* engine);
|
||||
|
||||
/* blit an image on DC */
|
||||
void rtgui_image_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* rect);
|
||||
struct rtgui_image_palette* rtgui_image_palette_create(rt_uint32_t ncolors);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,9 +4,23 @@
|
||||
#include <rtgui/rtgui.h>
|
||||
#include <rtgui/image.h>
|
||||
|
||||
void image_container_system_init(void);
|
||||
#ifdef RTGUI_IMAGE_CONTAINER
|
||||
/* image item in image container */
|
||||
struct rtgui_image_item
|
||||
{
|
||||
rtgui_image_t *image;
|
||||
char *filename;
|
||||
|
||||
rtgui_image_t* image_container_get(const char* filename);
|
||||
void image_container_put(rtgui_image_t* image);
|
||||
rt_uint32_t refcount;
|
||||
};
|
||||
typedef struct rtgui_image_item rtgui_image_item_t;
|
||||
|
||||
void rtgui_system_image_container_init(rt_bool_t load);
|
||||
|
||||
rtgui_image_item_t* rtgui_image_container_get(const char* filename);
|
||||
rtgui_image_item_t* rtgui_image_container_get_from_mem(const rt_uint8_t* mem, const char* type, rt_uint32_t len);
|
||||
|
||||
void rtgui_image_container_put(rtgui_image_item_t* item);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
#define RTGUI_DEFAULT_FONT_SIZE 12
|
||||
|
||||
#define RTGUI_USING_STDIO_FILERW
|
||||
#define RTGUI_IMAGE_CONTAINER
|
||||
#define RTGUI_IMAGE_XPM
|
||||
#define RTGUI_IMAGE_BMP
|
||||
// #define RTGUI_IMAGE_PNG
|
||||
// #define RTGUI_IMAGE_JPEG
|
||||
|
||||
Reference in New Issue
Block a user