Enlightenment CVS committal Author : raster Project : e17 Module : libs/evas
Dir : e17/libs/evas/src/lib/engines/common Modified Files: evas_image_load.c Log Message: ok - now support a first try guess based on extension - if that fails, or the extension is unknown to match a format, try all image loader modules until one succeeds - if all of these fail, give up. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/evas/src/lib/engines/common/evas_image_load.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -3 -r1.26 -r1.27 --- evas_image_load.c 15 Jan 2006 04:49:46 -0000 1.26 +++ evas_image_load.c 15 Jan 2006 05:04:31 -0000 1.27 @@ -5,8 +5,6 @@ static Evas_Image_Load_Func *evas_image_load_func = NULL; -static int evas_common_load_image_lookup(const char *name); - RGBA_Image * evas_common_load_image_from_file(const char *file, const char *key) { @@ -34,59 +32,57 @@ if (p) { p++; - -#ifdef BUILD_LOADER_PNG if (!strcasecmp(p, "png")) loader = "png"; -#endif -#ifdef BUILD_LOADER_JPEG - if ((!strcasecmp(p, "jpg")) || - (!strcasecmp(p, "jpeg")) || + if ((!strcasecmp(p, "jpg")) || (!strcasecmp(p, "jpeg")) || (!strcasecmp(p, "jfif"))) loader = "jpeg"; -#endif -#ifdef BUILD_LOADER_EET - if ((!strcasecmp(p, "eet")) || - (!strcasecmp(p, "edj")) || + if ((!strcasecmp(p, "eet")) || (!strcasecmp(p, "edj")) || (!strcasecmp(p, "eap"))) loader = "eet"; -#endif -#ifdef BUILD_LOADER_EDB if (!strcasecmp(p, "edb")) loader = "edb"; -#endif } - /* FIXME: - if no oloader can be guessed - we have to start hunting for - * one that might work - */ - if (!loader) - return NULL; + if (loader) + { + Evas_Module *em; + + em = evas_module_find_type(EVAS_MODULE_TYPE_IMAGE_LOADER, loader); + if (em) + { + if (evas_module_load(em)) + { + evas_image_load_func = em->functions; + if (evas_image_load_func->file_head(im, file, key)) + goto ok; + } + } + } for (l = evas_modules; l; l = l->next) { Evas_Module *em; - Evas_Module_Image_Loader *emil; em = l->data; if (em->type != EVAS_MODULE_TYPE_IMAGE_LOADER) continue; - if (!em->data) continue; - emil = (Evas_Module_Image_Loader *)em->data; - if (emil->id != evas_common_load_image_lookup(loader)) continue; - if (!evas_module_load(em)) return NULL; + if (!evas_module_load(em)) continue; evas_image_load_func = em->functions; - goto beach; + if (evas_image_load_func->file_head(im, file, key)) + { + if (evas_modules != l) + { + evas_modules = evas_list_remove_list(evas_modules, l); + evas_modules = evas_list_prepend(evas_modules, em); + } + goto ok; + } } + + evas_common_image_free(im); return NULL; - - beach: - if (!evas_image_load_func->file_head(im, file, key)) - { - evas_common_image_free(im); - return NULL; - } + ok: im->info.file = (char *)evas_stringshare_add(file); - if (key) im->info.key = (char *)evas_stringshare_add(key); evas_common_image_ref(im); return im; @@ -111,27 +107,3 @@ } } } - -static int -evas_common_load_image_lookup(const char *name) -{ - static int i = 1; - Evas_Module *em; - Evas_Module_Image_Loader *emil; - - if (!name) return RENDER_METHOD_INVALID; - /* search on the engines list for the name */ - em = evas_module_find_type(EVAS_MODULE_TYPE_IMAGE_LOADER, name); - - if(!em) return RENDER_METHOD_INVALID; - - emil = (Evas_Module_Image_Loader *)em->data; - if(!emil) - { - emil = (Evas_Module_Image_Loader *)malloc(sizeof(Evas_Module_Image_Loader)); - em->data = emil; - emil->id = i; - i++; - } - return emil->id; -} ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs