b9c0c8641355e8c7462683ed131f4d905f6e8592
[framework/uifw/ethumb.git] / src / lib / Ethumb.h
1 #ifndef __ETHUMB_H__
2 #define __ETHUMB_H__ 1
3
4 #include <Eina.h>
5
6 #ifdef EAPI
7 # undef EAPI
8 #endif
9
10 #ifdef _WIN32
11 # ifdef EFL_ETHUMB_BUILD
12 #  ifdef DLL_EXPORT
13 #   define EAPI __declspec(dllexport)
14 #   define GNUC_NULL_TERMINATED
15 #  else
16 #   define EAPI
17 #   define GNUC_NULL_TERMINATED
18 #  endif /* ! DLL_EXPORT */
19 # else
20 #  define EAPI __declspec(dllimport)
21 #  define GNUC_NULL_TERMINATED
22 # endif /* ! EFL_ETHUMB_BUILD */
23 #else
24 # ifdef __GNUC__
25 #  if __GNUC__ >= 4
26 #   define EAPI __attribute__ ((visibility("default")))
27 #   define GNUC_NULL_TERMINATED __attribute__((__sentinel__))
28 #  else
29 #   define EAPI
30 #  define GNUC_NULL_TERMINATED
31 #  endif
32 # else
33 #  define EAPI
34 #  define GNUC_NULL_TERMINATED
35 # endif
36 #endif /* ! _WIN32 */
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
42 /**
43  * @defgroup Ethumb Ethumb
44  *
45  * @{
46  */
47 /**
48  * @defgroup Ethumb_Basics Ethumb Basics
49  *
50  * Functions that all users must know of to use Ethumb.
51  *
52  * @{
53  */
54
55 /**
56  * @brief thumbnailer handle.
57  *
58  * The handle is returned by ethumb_new() and destroyed by ethumb_free().
59  */
60 typedef struct _Ethumb Ethumb;
61
62 /**
63  * @brief reports results of ethumb_generate().
64  *
65  * @param data extra context given to ethumb_generate().
66  * @param e handle of the current thumbnailer.
67  * @param success @c EINA_TRUE if generated or @c EINA_FALSE on errors.
68  */
69 typedef void (*Ethumb_Generate_Cb)(void *data, Ethumb *e, Eina_Bool success);
70
71 EAPI int ethumb_init(void);
72 EAPI int ethumb_shutdown(void);
73
74 EAPI Ethumb * ethumb_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
75 EAPI void ethumb_free(Ethumb *e);
76
77 /**
78  * @}
79  */
80
81 /**
82  * @defgroup Ethumb_Setup Ethumb Fine Tune Setup
83  *
84  * How to fine tune thumbnail generation, setting size, aspect,
85  * frames, quality and so on.
86  *
87  * @{
88  */
89
90 EAPI Eina_Bool    ethumb_frame_set(Ethumb *e, const char *theme_file, const char *group, const char *swallow) EINA_ARG_NONNULL(1);
91 EAPI void         ethumb_frame_get(const Ethumb *e, const char **theme_file, const char **group, const char **swallow) EINA_ARG_NONNULL(1);
92
93 EAPI void         ethumb_thumb_dir_path_set(Ethumb *e, const char *path) EINA_ARG_NONNULL(1);
94 EAPI const char  *ethumb_thumb_dir_path_get(const Ethumb *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
95
96 EAPI void         ethumb_thumb_category_set(Ethumb *e, const char *category) EINA_ARG_NONNULL(1);
97 EAPI const char  *ethumb_thumb_category_get(const Ethumb *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
98
99 EAPI void         ethumb_thumb_path_set(Ethumb *e, const char *path, const char *key) EINA_ARG_NONNULL(1);
100 EAPI void         ethumb_thumb_path_get(Ethumb *e, const char **path, const char **key) EINA_ARG_NONNULL(1);
101
102 typedef enum _Ethumb_Thumb_FDO_Size
103 {
104   ETHUMB_THUMB_NORMAL, /**< 128x128 as defined by FreeDesktop.Org standard */
105   ETHUMB_THUMB_LARGE   /**< 256x256 as defined by FreeDesktop.Org standard */
106 } Ethumb_Thumb_FDO_Size;
107
108 typedef enum _Ethumb_Thumb_Format
109 {
110    ETHUMB_THUMB_FDO,   /**< PNG as defined by FreeDesktop.Org standard */
111    ETHUMB_THUMB_JPEG,  /**< JPEGs are often smaller and faster to read/write */
112    ETHUMB_THUMB_EET    /**< EFL's own storage system, supports key parameter */
113 } Ethumb_Thumb_Format;
114
115 typedef enum _Ethumb_Thumb_Aspect
116 {
117   ETHUMB_THUMB_KEEP_ASPECT, /**< keep original proportion between width and height */
118   ETHUMB_THUMB_IGNORE_ASPECT, /**< ignore aspect and foce it to match thumbnail's width and height */
119   ETHUMB_THUMB_CROP /**< keep aspect but crop (cut) the largest dimension */
120 } Ethumb_Thumb_Aspect;
121
122 typedef enum _Ethumb_Thumb_Orientation
123 {
124   ETHUMB_THUMB_ORIENT_NONE,     /**< keep orientation as pixel data is */
125   ETHUMB_THUMB_ROTATE_90_CW,    /**< rotate 90° clockwise */
126   ETHUMB_THUMB_ROTATE_180,      /**< rotate 180° */
127   ETHUMB_THUMB_ROTATE_90_CCW,   /**< rotate 90° counter-clockwise */
128   ETHUMB_THUMB_FLIP_HORIZONTAL, /**< flip horizontally */
129   ETHUMB_THUMB_FLIP_VERTICAL,   /**< flip vertically */
130   ETHUMB_THUMB_FLIP_TRANSPOSE,  /**< transpose */
131   ETHUMB_THUMB_FLIP_TRANSVERSE, /**< transverse */
132   ETHUMB_THUMB_ORIENT_ORIGINAL  /**< use orientation from metadata (EXIF-only currently) */
133 } Ethumb_Thumb_Orientation;
134
135 EAPI void ethumb_thumb_fdo_set(Ethumb *e, Ethumb_Thumb_FDO_Size s) EINA_ARG_NONNULL(1);
136
137 EAPI void ethumb_thumb_size_set(Ethumb *e, int tw, int th) EINA_ARG_NONNULL(1);
138 EAPI void ethumb_thumb_size_get(const Ethumb *e, int *tw, int *th) EINA_ARG_NONNULL(1);
139
140 EAPI void                     ethumb_thumb_format_set(Ethumb *e, Ethumb_Thumb_Format f) EINA_ARG_NONNULL(1);
141 EAPI Ethumb_Thumb_Format      ethumb_thumb_format_get(const Ethumb *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
142
143 EAPI void                     ethumb_thumb_aspect_set(Ethumb *e, Ethumb_Thumb_Aspect a) EINA_ARG_NONNULL(1);
144 EAPI Ethumb_Thumb_Aspect      ethumb_thumb_aspect_get(const Ethumb *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
145
146 EAPI void                     ethumb_thumb_orientation_set(Ethumb *e, Ethumb_Thumb_Orientation o) EINA_ARG_NONNULL(1);
147 EAPI Ethumb_Thumb_Orientation ethumb_thumb_orientation_get(const Ethumb *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
148
149 EAPI void         ethumb_thumb_crop_align_set(Ethumb *e, float x, float y) EINA_ARG_NONNULL(1);
150 EAPI void         ethumb_thumb_crop_align_get(const Ethumb *e, float *x, float *y) EINA_ARG_NONNULL(1);
151
152 EAPI void         ethumb_thumb_quality_set(Ethumb *e, int quality) EINA_ARG_NONNULL(1);
153 EAPI int          ethumb_thumb_quality_get(const Ethumb *e) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE;
154
155 EAPI void         ethumb_thumb_compress_set(Ethumb *e, int compress) EINA_ARG_NONNULL(1);
156 EAPI int          ethumb_thumb_compress_get(const Ethumb *e) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE;
157
158 EAPI void         ethumb_video_start_set(Ethumb *e, float start) EINA_ARG_NONNULL(1);
159 EAPI float        ethumb_video_start_get(const Ethumb *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
160 EAPI void         ethumb_video_time_set(Ethumb *e, float time) EINA_ARG_NONNULL(1);
161 EAPI float        ethumb_video_time_get(const Ethumb *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
162 EAPI void         ethumb_video_interval_set(Ethumb *e, float interval) EINA_ARG_NONNULL(1);
163 EAPI float        ethumb_video_interval_get(const Ethumb *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
164 EAPI void         ethumb_video_ntimes_set(Ethumb *e, unsigned int ntimes) EINA_ARG_NONNULL(1);
165 EAPI unsigned int ethumb_video_ntimes_get(const Ethumb *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
166 EAPI void         ethumb_video_fps_set(Ethumb *e, unsigned int fps) EINA_ARG_NONNULL(1);
167 EAPI unsigned int ethumb_video_fps_get(const Ethumb *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
168
169
170 EAPI void         ethumb_document_page_set(Ethumb *e, unsigned int page) EINA_ARG_NONNULL(1);
171 EAPI unsigned int ethumb_document_page_get(const Ethumb *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
172 /**
173  * @}
174  */
175
176 /**
177  * @addtogroup Ethumb_Basics Ethumb Basics
178  * @{
179  */
180 EAPI Eina_Bool ethumb_file_set(Ethumb *e, const char *path, const char *key) EINA_ARG_NONNULL(1, 2);
181 EAPI void      ethumb_file_get(const Ethumb *e, const char **path, const char **key) EINA_ARG_NONNULL(1);
182 EAPI void      ethumb_file_free(Ethumb *e) EINA_ARG_NONNULL(1);
183
184 EAPI Eina_Bool ethumb_generate(Ethumb *e, Ethumb_Generate_Cb finished_cb, const void *data, Eina_Free_Cb free_data) EINA_ARG_NONNULL(1, 2);
185 EAPI Eina_Bool ethumb_exists(Ethumb *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
186 /**
187  * @}
188  */
189
190 /**
191  * @}
192  */
193
194 #ifdef __cplusplus
195 }
196 #endif
197 #endif /* __ETHUMB_H__ */