aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/src/modules/savers/eet/evas_image_save_eet.c
blob: 4eb717647e52fdd1bee7855b8f4278ca9744e4c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifdef HAVE_CONFIG_H
# include "config.h"  /* so that EAPI in Eet.h is correctly defined */
#endif

#include <Eet.h>

#include "evas_common.h"
#include "evas_private.h"

static int evas_image_save_file_eet(RGBA_Image *im, const char *file, const char *key, int quality, int compress);

static Evas_Image_Save_Func evas_image_save_eet_func =
{
   evas_image_save_file_eet
};

static int
evas_image_save_file_eet(RGBA_Image *im, const char *file, const char *key, int quality, int compress)
{
   Eet_File            *ef;
   int alpha = 0, lossy = 0, ok = 0;
   DATA32   *data;

   if (!im || !im->image.data || !file)
      return 0;

   ef = eet_open((char *)file, EET_FILE_MODE_READ_WRITE);
   if (!ef) ef = eet_open((char *)file, EET_FILE_MODE_WRITE);
   if (!ef) return 0;
   if ((quality <= 100) || (compress < 0)) lossy = 1;
   if (im->cache_entry.flags.alpha) alpha = 1;
//   if (alpha)
//     {
//       data = malloc(im->image->w * im->image->h * sizeof(DATA32));
//       if (!data)
//	 {
//	   eet_close(ef);
//	   return 0;
//	 }
//       memcpy(data, im->image->data, im->image->w * im->image->h * sizeof(DATA32));
//       evas_common_convert_argb_unpremul(data, im->image->w * im->image->h);
//     }
//   else
       data = im->image.data;
   ok = eet_data_image_write(ef, (char *)key, data,
			     im->cache_entry.w, im->cache_entry.h, alpha, compress,
			     quality, lossy);
//   if (alpha)
//     free(data);
   eet_close(ef);
   return ok;
}

static int
module_open(Evas_Module *em)
{
   if (!em) return 0;
   em->functions = (void *)(&evas_image_save_eet_func);
   return 1;
}

static void
module_close(Evas_Module *em __UNUSED__)
{
}

static Evas_Module_Api evas_modapi =
{
   EVAS_MODULE_API_VERSION,
   "eet",
   "none",
   {
     module_open,
     module_close
   }
};

EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_IMAGE_SAVER, image_saver, eet);

#ifndef EVAS_STATIC_BUILD_EET
EVAS_EINA_MODULE_DEFINE(image_saver, eet);
#endif