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_private.h"
8 #include "evas_private.h"
9
10 static int evas_image_save_file_eet(RGBA_Image *im, const char *file, const char *key, int quality, int compress, const char *encoding);
11
12 static Evas_Image_Save_Func evas_image_save_eet_func =
13 {
14 evas_image_save_file_eet
15 };
16
17 static int
evas_image_save_file_eet(RGBA_Image * im,const char * file,const char * key,int quality,int compress,const char * encoding EINA_UNUSED)18 evas_image_save_file_eet(RGBA_Image *im, const char *file, const char *key,
19 int quality, int compress, const char *encoding EINA_UNUSED)
20 {
21 Eet_File *ef;
22 int alpha = 0, lossy = 0, ok = 0;
23 DATA32 *data;
24
25 if (!im || !im->image.data || !file)
26 return 0;
27
28 ef = eet_open((char *)file, EET_FILE_MODE_READ_WRITE);
29 if (!ef) ef = eet_open((char *)file, EET_FILE_MODE_WRITE);
30 if (!ef) return 0;
31 if ((quality <= 100) || (compress < 0)) lossy = 1;
32 if (im->cache_entry.flags.alpha) alpha = 1;
33 // if (alpha)
34 // {
35 // data = malloc(im->image->w * im->image->h * sizeof(DATA32));
36 // if (!data)
37 // {
38 // eet_close(ef);
39 // return 0;
40 // }
41 // memcpy(data, im->image->data, im->image->w * im->image->h * sizeof(DATA32));
42 // evas_common_convert_argb_unpremul(data, im->image->w * im->image->h);
43 // }
44 // else
45 data = im->image.data;
46 ok = eet_data_image_write(ef, (char *)key, data,
47 im->cache_entry.w, im->cache_entry.h, alpha, compress,
48 quality, lossy);
49 // if (alpha)
50 // free(data);
51 eet_close(ef);
52 return ok;
53 }
54
55 static int
module_open(Evas_Module * em)56 module_open(Evas_Module *em)
57 {
58 if (!em) return 0;
59 em->functions = (void *)(&evas_image_save_eet_func);
60 return 1;
61 }
62
63 static void
module_close(Evas_Module * em EINA_UNUSED)64 module_close(Evas_Module *em EINA_UNUSED)
65 {
66 }
67
68 static Evas_Module_Api evas_modapi =
69 {
70 EVAS_MODULE_API_VERSION,
71 "eet",
72 "none",
73 {
74 module_open,
75 module_close
76 }
77 };
78
79 EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_IMAGE_SAVER, image_saver, eet);
80
81 #ifndef EVAS_STATIC_BUILD_EET
82 EVAS_EINA_MODULE_DEFINE(image_saver, eet);
83 #endif
84
85