aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/src/modules/loaders/eet/evas_image_load_eet.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/evas/src/modules/loaders/eet/evas_image_load_eet.c')
-rw-r--r--libraries/evas/src/modules/loaders/eet/evas_image_load_eet.c183
1 files changed, 0 insertions, 183 deletions
diff --git a/libraries/evas/src/modules/loaders/eet/evas_image_load_eet.c b/libraries/evas/src/modules/loaders/eet/evas_image_load_eet.c
deleted file mode 100644
index f86246a..0000000
--- a/libraries/evas/src/modules/loaders/eet/evas_image_load_eet.c
+++ /dev/null
@@ -1,183 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h" /* so that EAPI in Eet.h is correctly defined */
3#endif
4
5#include <Eet.h>
6
7#include "evas_common.h"
8#include "evas_private.h"
9
10
11static Eina_Bool evas_image_load_file_head_eet(Image_Entry *ie, const char *file, const char *key, int *error) EINA_ARG_NONNULL(1, 2, 4);
12static Eina_Bool evas_image_load_file_data_eet(Image_Entry *ie, const char *file, const char *key, int *error) EINA_ARG_NONNULL(1, 2, 4);
13
14Evas_Image_Load_Func evas_image_load_eet_func =
15{
16 EINA_TRUE,
17 evas_image_load_file_head_eet,
18 evas_image_load_file_data_eet,
19 NULL,
20 EINA_FALSE
21};
22
23
24static Eina_Bool
25evas_image_load_file_head_eet(Image_Entry *ie, const char *file, const char *key, int *error)
26{
27 int alpha, compression, quality, lossy;
28 unsigned int w, h;
29 Eet_File *ef;
30 int ok;
31 Eina_Bool res = EINA_FALSE;
32
33 if (!key)
34 {
35 *error = EVAS_LOAD_ERROR_DOES_NOT_EXIST;
36 return EINA_FALSE;
37 }
38
39 ef = eet_open((char *)file, EET_FILE_MODE_READ);
40 if (!ef)
41 {
42 *error = EVAS_LOAD_ERROR_DOES_NOT_EXIST;
43 return EINA_FALSE;
44 }
45 ok = eet_data_image_header_read(ef, key,
46 &w, &h, &alpha, &compression, &quality, &lossy);
47 if (!ok)
48 {
49 *error = EVAS_LOAD_ERROR_DOES_NOT_EXIST;
50 goto on_error;
51 }
52 if (IMG_TOO_BIG(w, h))
53 {
54 *error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
55 goto on_error;
56 }
57 if (alpha) ie->flags.alpha = 1;
58 ie->w = w;
59 ie->h = h;
60 res = EINA_TRUE;
61 *error = EVAS_LOAD_ERROR_NONE;
62
63 on_error:
64 eet_close(ef);
65 return res;
66}
67
68Eina_Bool
69evas_image_load_file_data_eet(Image_Entry *ie, const char *file, const char *key, int *error)
70{
71 unsigned int w, h;
72 int alpha, compression, quality, lossy, ok;
73 Eet_File *ef;
74 DATA32 *body, *p, *end, *data;
75 DATA32 nas = 0;
76 Eina_Bool res = EINA_FALSE;
77
78 if (!key)
79 {
80 *error = EVAS_LOAD_ERROR_DOES_NOT_EXIST;
81 return EINA_FALSE;
82 }
83 if (ie->flags.loaded)
84 {
85 *error = EVAS_LOAD_ERROR_NONE;
86 return EINA_TRUE;
87 }
88 ef = eet_open(file, EET_FILE_MODE_READ);
89 if (!ef)
90 {
91 *error = EVAS_LOAD_ERROR_DOES_NOT_EXIST;
92 return EINA_FALSE;
93 }
94 ok = eet_data_image_header_read(ef, key,
95 &w, &h, &alpha, &compression, &quality, &lossy);
96 if (IMG_TOO_BIG(w, h))
97 {
98 *error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
99 goto on_error;
100 }
101 if (!ok)
102 {
103 *error = EVAS_LOAD_ERROR_DOES_NOT_EXIST;
104 goto on_error;
105 }
106 evas_cache_image_surface_alloc(ie, w, h);
107 data = evas_cache_image_pixels(ie);
108 if (!data)
109 {
110 *error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
111 goto on_error;
112 }
113 ok = eet_data_image_read_to_surface(ef, key, 0, 0,
114 data, w, h, w * 4,
115 &alpha, &compression, &quality, &lossy);
116 if (!ok)
117 {
118 *error = EVAS_LOAD_ERROR_GENERIC;
119 goto on_error;
120 }
121 if (alpha)
122 {
123 ie->flags.alpha = 1;
124
125 body = evas_cache_image_pixels(ie);
126
127 end = body +(w * h);
128 for (p = body; p < end; p++)
129 {
130 DATA32 r, g, b, a;
131
132 a = A_VAL(p);
133 r = R_VAL(p);
134 g = G_VAL(p);
135 b = B_VAL(p);
136 if ((a == 0) || (a == 255)) nas++;
137 if (r > a) r = a;
138 if (g > a) g = a;
139 if (b > a) b = a;
140 *p = ARGB_JOIN(a, r, g, b);
141 }
142 if ((ALPHA_SPARSE_INV_FRACTION * nas) >= (ie->w * ie->h))
143 ie->flags.alpha_sparse = 1;
144 }
145// result is already premultiplied now if u compile with edje
146// evas_common_image_premul(im);
147 *error = EVAS_LOAD_ERROR_NONE;
148 res = EINA_TRUE;
149
150 on_error:
151 eet_close(ef);
152 return res;
153}
154
155static int
156module_open(Evas_Module *em)
157{
158 if (!em) return 0;
159 em->functions = (void *)(&evas_image_load_eet_func);
160 return 1;
161}
162
163static void
164module_close(Evas_Module *em __UNUSED__)
165{
166}
167
168static Evas_Module_Api evas_modapi =
169{
170 EVAS_MODULE_API_VERSION,
171 "eet",
172 "none",
173 {
174 module_open,
175 module_close
176 }
177};
178
179EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_IMAGE_LOADER, image_loader, eet);
180
181#ifndef EVAS_STATIC_BUILD_EET
182EVAS_EINA_MODULE_DEFINE(image_loader, eet);
183#endif