Mercurial > MadButterfly
comparison include/mb_img_ldr.h @ 257:50d253d0fcba
Simple image loader and image shape.
- img_ldr.c is a simple image loader that rooted on a directory
specified when a loader instance been created.
- sh_image_t is corresponding shape of image tag in SVG.
- This changeset is still buggy. It need more testing.
- svg2code.py is not ready for image tag.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Thu, 15 Jan 2009 16:46:47 +0800 |
parents | |
children | 29acbd8a0dd0 |
comparison
equal
deleted
inserted
replaced
256:cac9ad3df633 | 257:50d253d0fcba |
---|---|
1 #ifndef __MB_IMG_LDR_H_ | |
2 #define __MB_IMG_LDR_H_ | |
3 | |
4 typedef struct _mb_img_data mb_img_data_t; | |
5 typedef struct _mb_img_ldr mb_img_ldr_t; | |
6 | |
7 typedef enum _mb_img_fmt { | |
8 MB_IFMT_DUMMY, | |
9 MB_IFMT_ARGB32, | |
10 MB_IFMT_RGB24, | |
11 MB_IFMT_A8, | |
12 MB_IFMT_A1, | |
13 MB_IFMT_RGB16_565 | |
14 } mb_img_fmt_t; | |
15 | |
16 /*! \brief Encapsulate image. | |
17 * | |
18 * The format and content of an image is encapsulated by imag_data_t. | |
19 * We hope someday, we can create an abstract backend layer that | |
20 * can deal with image data. | |
21 */ | |
22 struct _mb_img_data { | |
23 /*! \brief Content of the image. */ | |
24 void *content; | |
25 int width, height; | |
26 int stride; /*!< \brief Number of bytes a row */ | |
27 mb_img_fmt_t fmt; | |
28 /*! \brief Release the image that was loaded by the loader. */ | |
29 void (*free)(mb_img_data_t *img); | |
30 }; | |
31 #define MB_IMG_DATA_FREE(img) (img)->free(img) | |
32 | |
33 /*! \brief Image loader. | |
34 * | |
35 * An image loader take a ID and find out the corresponding | |
36 * image from filesystem or somewhere. Image ID is a hierachical | |
37 * structured path. It is relative to the root of image database. | |
38 * Users of a loader do not need to know where the database is. | |
39 * The location can be configured when a loader been instantiated. | |
40 * But, it is invisible when loading images by an image loader. | |
41 */ | |
42 struct _mb_img_ldr { | |
43 /*! \brief Load a image with specified ID. */ | |
44 mb_img_data_t *(*load)(mb_img_ldr_t *ldr, const char *img_id); | |
45 /*! \brief Free the loader. */ | |
46 void (*free)(mb_img_ldr_t *ldr); | |
47 }; | |
48 #define MB_IMG_LDR_FREE(ldr) (ldr)->free(ldr) | |
49 | |
50 /*! \brief Create a simple image loader. | |
51 * | |
52 * \param img_repository is a repository where images are loaded from. | |
53 * \return NULL for error. | |
54 */ | |
55 extern mb_img_ldr_t *simple_mb_img_ldr_new(const char *img_repository); | |
56 | |
57 #endif /* __MB_IMG_LDR_H_ */ |