move around - flatter.
[profile/ivi/evas.git] / src / lib / engines / common / evas_image_save.c
1 /*
2  * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3  */
4
5 #ifdef HAVE_CONFIG_H
6 # include "config.h"
7 #endif
8
9 #include "evas_options.h"
10
11 #include "evas_common.h"
12 #include "evas_private.h"
13
14
15 extern Evas_List *evas_modules;
16
17 int
18 evas_common_save_image_to_file(RGBA_Image *im, const char *file, const char *key, int quality, int compress)
19 {
20    Evas_Image_Save_Func *evas_image_save_func = NULL;
21    char *p;
22    char *saver = NULL;
23
24    p = strrchr(file, '.');
25    if (p)
26      {
27         p++;
28
29         if (!strcasecmp(p, "png"))
30           saver = "png";
31         if ((!strcasecmp(p, "jpg")) || (!strcasecmp(p, "jpeg")) ||
32             (!strcasecmp(p, "jfif")))
33           saver = "jpeg";
34         if ((!strcasecmp(p, "eet")) || (!strcasecmp(p, "edj")) ||
35             (!strcasecmp(p, "eap")))
36           saver = "eet";
37         if (!strcasecmp(p, "edb"))
38           saver = "edb";
39      }
40
41    if (saver)
42      {
43         Evas_Module *em;
44
45         em = evas_module_find_type(EVAS_MODULE_TYPE_IMAGE_SAVER, saver);
46         if (em)
47           {
48              evas_module_use(em);
49              if (evas_module_load(em))
50                {
51                   evas_image_save_func = em->functions;
52                   return evas_image_save_func->image_save(im, file, key, quality, compress);
53                }
54           }
55      }
56    return 0;
57 }