Mercurial > MadButterfly
annotate include/mb_img_ldr.h @ 581:953acea89f76 openvg
dummy implementation of graphic engine
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sat, 19 Jun 2010 11:43:53 +0800 |
parents | 43900cae1d49 |
children | 586e50f82c1f |
rev | line source |
---|---|
257
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1 #ifndef __MB_IMG_LDR_H_ |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
2 #define __MB_IMG_LDR_H_ |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
3 |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
4 typedef struct _mb_img_data mb_img_data_t; |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
5 typedef struct _mb_img_ldr mb_img_ldr_t; |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
6 |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
7 typedef enum _mb_img_fmt { |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
8 MB_IFMT_DUMMY, |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
9 MB_IFMT_ARGB32, |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
10 MB_IFMT_RGB24, |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
11 MB_IFMT_A8, |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
12 MB_IFMT_A1, |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
13 MB_IFMT_RGB16_565 |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
14 } mb_img_fmt_t; |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
15 |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
16 /*! \brief Encapsulate image. |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
17 * |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
18 * The format and content of an image is encapsulated by imag_data_t. |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
19 * We hope someday, we can create an abstract backend layer that |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
20 * can deal with image data. |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
21 */ |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
22 struct _mb_img_data { |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
23 /*! \brief Content of the image. */ |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
24 void *content; |
268
43900cae1d49
Support resizing for image.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
25 int w, h; |
257
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
26 int stride; /*!< \brief Number of bytes a row */ |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
27 mb_img_fmt_t fmt; |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
28 /*! \brief Release the image that was loaded by the loader. */ |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
29 void (*free)(mb_img_data_t *img); |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
30 }; |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
31 #define MB_IMG_DATA_FREE(img) (img)->free(img) |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
32 |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
33 /*! \brief Image loader. |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
34 * |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
35 * An image loader take a ID and find out the corresponding |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
36 * image from filesystem or somewhere. Image ID is a hierachical |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
37 * structured path. It is relative to the root of image database. |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
38 * Users of a loader do not need to know where the database is. |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
39 * The location can be configured when a loader been instantiated. |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
40 * But, it is invisible when loading images by an image loader. |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
41 */ |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
42 struct _mb_img_ldr { |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
43 /*! \brief Load a image with specified ID. */ |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
44 mb_img_data_t *(*load)(mb_img_ldr_t *ldr, const char *img_id); |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
45 /*! \brief Free the loader. */ |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
46 void (*free)(mb_img_ldr_t *ldr); |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
47 }; |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
48 #define MB_IMG_LDR_FREE(ldr) (ldr)->free(ldr) |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
49 #define MB_IMG_LDR_LOAD(ldr, img_id) (ldr)->load(ldr, img_id) |
257
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
50 |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
51 /*! \brief Create a simple image loader. |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
52 * |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
53 * \param img_repository is a repository where images are loaded from. |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
54 * \return NULL for error. |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
55 */ |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
56 extern mb_img_ldr_t *simple_mb_img_ldr_new(const char *img_repository); |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
57 |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
58 #endif /* __MB_IMG_LDR_H_ */ |