1 #include "evas_common.h"
2 #include "evas_private.h"
8 #define SWAP32(x) (x) = ((((x) & 0x000000ff ) << 24) | (((x) & 0x0000ff00 ) << 8) | (((x) & 0x00ff0000 ) >> 8) | (((x) & 0xff000000 ) >> 24))
11 int evas_image_load_file_head_edb(Image_Entry *ie, const char *file, const char *key);
12 int evas_image_load_file_data_edb(Image_Entry *ie, const char *file, const char *key);
14 Evas_Image_Load_Func evas_image_load_edb_func =
16 evas_image_load_file_head_edb,
17 evas_image_load_file_data_edb
22 evas_image_load_file_head_edb(Image_Entry *ie, const char *file, const char *key)
24 int w, h, alpha, compression, size;
29 if ((!file) || (!key)) return 0;
30 db = e_db_open_read((char *)file);
32 ret = e_db_data_get(db, (char *)key, &size);
44 memcpy(header, ret, 32);
45 #ifdef WORDS_BIGENDIAN
49 for (i = 0; i < 8; i++) SWAP32(header[i]);
52 if (header[0] != 0xac1dfeed)
60 if ((w < 1) || (h < 1) || (w > 8192) || (h > 8192))
67 compression = header[4];
69 if ((compression == 0) && (size < ((w * h * 4) + 32)))
75 if (alpha) ie->flags.alpha = 1;
84 evas_image_load_file_data_edb(Image_Entry *ie, const char *file, const char *key)
86 int w, h, alpha, compression, size;
93 if ((!file) || (!key)) return 0;
94 db = e_db_open_read((char *)file);
96 ret = e_db_data_get(db, (char *)key, &size);
108 memcpy(header, ret, 32);
109 #ifdef WORDS_BIGENDIAN
113 for (i = 0; i < 8; i++) SWAP32(header[i]);
116 if (header[0] != 0xac1dfeed)
124 if ((w < 1) || (h < 1) || (w > 8192) || (h > 8192))
132 compression = header[4];
134 if ((compression == 0) && (size < ((w * h * 4) + 32)))
140 if (alpha) ie->flags.alpha = 1;
142 evas_cache_image_surface_alloc(ie, w, h);
143 surface = evas_cache_image_pixels(ie);
152 #ifdef WORDS_BIGENDIAN
156 memcpy(surface, body, w * h * sizeof(DATA32));
157 for (x = 0; x < (w * h); x++) SWAP32(surface[x]);
160 memcpy(surface, body, w * h * sizeof(DATA32));
167 dlen = w * h * sizeof(DATA32);
168 uncompress((Bytef *)surface, &dlen, (Bytef *)body,
169 (uLongf)(size - 32));
170 #ifdef WORDS_BIGENDIAN
174 for (x = 0; x < (w * h); x++) SWAP32(surface[x]);
178 evas_common_image_premul(ie);
185 module_open(Evas_Module *em)
188 em->functions = (void *)(&evas_image_load_edb_func);
198 EAPI Evas_Module_Api evas_modapi =
200 EVAS_MODULE_API_VERSION,
201 EVAS_MODULE_TYPE_IMAGE_LOADER,