2 # include "config.h" /* so that EAPI in Eet.h is correctly defined */
7 #include "evas_common.h"
8 #include "evas_private.h"
11 int evas_image_load_file_head_eet(Image_Entry *ie, const char *file, const char *key);
12 int evas_image_load_file_data_eet(Image_Entry *ie, const char *file, const char *key);
14 Evas_Image_Load_Func evas_image_load_eet_func =
16 evas_image_load_file_head_eet,
17 evas_image_load_file_data_eet
22 evas_image_load_file_head_eet(Image_Entry *ie, const char *file, const char *key)
24 int alpha, compression, quality, lossy;
30 if ((!file) || (!key)) return 0;
31 ef = eet_open((char *)file, EET_FILE_MODE_READ);
33 ok = eet_data_image_header_read(ef, key,
34 &w, &h, &alpha, &compression, &quality, &lossy);
35 if (!ok) goto on_error;
36 if (alpha) ie->flags.alpha = 1;
47 evas_image_load_file_data_eet(Image_Entry *ie, const char *file, const char *key)
50 int alpha, compression, quality, lossy, ok;
52 DATA32 *body, *p, *end;
56 if ((!file) || (!key)) return 0;
57 if (ie->flags.loaded) return 1;
58 ef = eet_open(file, EET_FILE_MODE_READ);
60 ok = eet_data_image_header_read(ef, key,
61 &w, &h, &alpha, &compression, &quality, &lossy);
62 if (!ok) goto on_error;
63 evas_cache_image_surface_alloc(ie, w, h);
64 ok = eet_data_image_read_to_surface(ef, key, 0, 0,
65 evas_cache_image_pixels(ie), w, h, w * 4,
66 &alpha, &compression, &quality, &lossy);
67 if (!ok) goto on_error;
72 body = evas_cache_image_pixels(ie);
75 for (p = body; p < end; p++)
83 if ((a == 0) || (a == 255)) nas++;
87 *p = ARGB_JOIN(a, r, g, b);
89 if ((ALPHA_SPARSE_INV_FRACTION * nas) >= (ie->w * ie->h))
90 ie->flags.alpha_sparse = 1;
92 // result is already premultiplied now if u compile with edje
93 // evas_common_image_premul(im);
102 module_open(Evas_Module *em)
105 em->functions = (void *)(&evas_image_load_eet_func);
115 EAPI Evas_Module_Api evas_modapi =
117 EVAS_MODULE_API_VERSION,
118 EVAS_MODULE_TYPE_IMAGE_LOADER,