int evas_common_save_image_to_file(RGBA_Image *im, const char *file, const char *key, int quality, int compress) { Evas_Image_Save_Func *evas_image_save_func = NULL; char *p; char *saver = NULL; p = strrchr(file, '.'); if (p) { p++; if (!strcasecmp(p, "png")) saver = "png"; if ((!strcasecmp(p, "jpg")) || (!strcasecmp(p, "jpeg")) || (!strcasecmp(p, "jfif"))) saver = "jpeg"; if ((!strcasecmp(p, "eet")) || (!strcasecmp(p, "edj")) || (!strcasecmp(p, "eap"))) saver = "eet"; if (!strcasecmp(p, "webp")) saver = "webp"; if (!strcasecmp(p, "tgv")) saver = "tgv"; } if (saver) { Evas_Module *em; em = evas_module_find_type(EVAS_MODULE_TYPE_IMAGE_SAVER, saver); if (em) { evas_module_use(em); if (evas_module_load(em)) { evas_image_save_func = em->functions; return evas_image_save_func->image_save(im, file, key, quality, compress); } } } return 0; }
EAPI int _evas_module_engine_inherit(Evas_Func *funcs, char *name) { Evas_Module *em; em = evas_module_find_type(EVAS_MODULE_TYPE_ENGINE, name); if (em) { if (evas_module_load(em)) { /* FIXME: no way to unref */ evas_module_ref(em); evas_module_use(em); *funcs = *((Evas_Func *)(em->functions)); return 1; } } return 0; }
static void * _image_file_open(Eina_File *fd, Eina_Stringshare *key, Evas_Image_Load_Opts *load_opts, Evas_Module *module, Evas_Image_Property *property, Evas_Image_Animated *animated, Evas_Image_Load_Func **pfuncs) { int error = EVAS_LOAD_ERROR_NONE; void *loader_data = NULL; Evas_Image_Load_Func *funcs = NULL; *pfuncs = NULL; if (!evas_module_load(module)) goto unload; funcs = module->functions; if (!funcs) goto unload; evas_module_use(module); memset(animated, 0, sizeof (*animated)); loader_data = funcs->file_open(fd, key, load_opts, animated, &error); if (!loader_data || (error != EVAS_LOAD_ERROR_NONE)) goto unload; if (!funcs->file_head(loader_data, property, &error)) goto unload; if (error != EVAS_LOAD_ERROR_NONE) goto unload; *pfuncs = funcs; return loader_data; unload: if (funcs && loader_data) funcs->file_close(loader_data); evas_module_unload(module); return NULL; }
static Eina_Bool _evas_image_file_header(Evas_Module *em, Image_Entry *ie, int *error) { Evas_Image_Load_Func *evas_image_load_func = NULL; Eina_Bool r = EINA_TRUE; if (!evas_module_load(em)) goto load_error; evas_image_load_func = em->functions; evas_module_use(em); *error = EVAS_LOAD_ERROR_NONE; if (evas_image_load_func) { Evas_Image_Property property; const char *file; if (!ie->f) { ie->f = eina_file_open(ie->file, EINA_FALSE); file = ie->file; } else { file = eina_file_filename_get(ie->f); } if (!ie->f) { *error = EVAS_LOAD_ERROR_DOES_NOT_EXIST; goto load_error; } ie->loader_data = evas_image_load_func->file_open(ie->f, ie->key, &ie->load_opts, &ie->animated, error); if (!ie->loader_data) { goto load_error; } memset(&property, 0, sizeof (Evas_Image_Property)); if (evas_image_load_func->file_head(ie->loader_data, &property, error) && (*error == EVAS_LOAD_ERROR_NONE)) { DBG("loaded file head using module '%s' (%p): %s", em->definition->name, em, file); ie->w = property.w; ie->h = property.h; ie->scale = property.scale; ie->flags.alpha = property.alpha; if (ie->load_opts.orientation && ie->load_opts.degree != 0) ie->flags.rotated = EINA_TRUE; r = EINA_FALSE; } else { evas_image_load_func->file_close(ie->loader_data); ie->loader_data = NULL; evas_module_unload(em); INF("failed to load file head using module '%s' (%p): " "%s (%s)", em->definition->name, em, file, evas_load_error_str(*error)); } } else { load_error: evas_module_unload(em); WRN("failed to load module '%s'.", em->definition->name); } return r; }