2008-07-19 11:32:32 -07:00
|
|
|
/*
|
|
|
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
|
|
|
*/
|
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
#include "evas_common.h"
|
|
|
|
#include "evas_private.h"
|
2009-05-01 00:11:07 -07:00
|
|
|
#include "evas_cs.h"
|
2002-11-08 00:02:15 -08:00
|
|
|
|
2007-07-16 00:25:35 -07:00
|
|
|
struct ext_loader_s {
|
|
|
|
const char* extention;
|
|
|
|
const char* loader;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct ext_loader_s loaders[] = {
|
|
|
|
{ "png", "png" },
|
|
|
|
{ "jpg", "jpeg" },
|
|
|
|
{ "jpeg", "jpeg" },
|
|
|
|
{ "jfif", "jpeg" },
|
|
|
|
{ "eet", "eet" },
|
|
|
|
{ "edj", "eet" },
|
|
|
|
{ "eap", "eet" },
|
|
|
|
{ "edb", "edb" },
|
|
|
|
{ "xpm", "xpm" },
|
|
|
|
{ "tiff", "tiff" },
|
|
|
|
{ "tif", "tiff" },
|
|
|
|
{ "svg", "svg" },
|
2007-07-18 02:04:30 -07:00
|
|
|
{ "svgz", "svg" },
|
2008-03-01 07:27:20 -08:00
|
|
|
{ "gif", "gif" },
|
|
|
|
{ "pbm", "pmaps" },
|
|
|
|
{ "pgm", "pmaps" },
|
|
|
|
{ "ppm", "pmaps" },
|
|
|
|
{ "pnm", "pmaps" }
|
2007-07-16 00:25:35 -07:00
|
|
|
};
|
|
|
|
|
2009-06-16 06:01:36 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_evas_image_foreach_loader(const Eina_Hash *hash, const char *key, Evas_Module *em, Image_Entry *ie)
|
|
|
|
{
|
|
|
|
Evas_Image_Load_Func *evas_image_load_func = NULL;
|
|
|
|
|
|
|
|
if (!evas_module_load(em)) return EINA_TRUE;
|
|
|
|
evas_image_load_func = em->functions;
|
|
|
|
evas_module_use(em);
|
|
|
|
if (evas_image_load_func && evas_image_load_func->file_head(ie, ie->file, ie->key))
|
|
|
|
{
|
|
|
|
ie->info.module = (void*) em;
|
|
|
|
ie->info.loader = (void*) evas_image_load_func;
|
|
|
|
evas_module_ref((Evas_Module*) ie->info.module);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2009-05-02 08:53:48 -07:00
|
|
|
EAPI int
|
2008-04-11 17:32:30 -07:00
|
|
|
evas_common_load_rgba_image_module_from_file(Image_Entry *ie)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2006-01-14 22:21:05 -08:00
|
|
|
Evas_Image_Load_Func *evas_image_load_func = NULL;
|
2007-07-16 00:25:35 -07:00
|
|
|
const char *loader = NULL;
|
|
|
|
Evas_Module *em;
|
2008-04-11 17:32:30 -07:00
|
|
|
char *dot;
|
|
|
|
int i;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2009-05-01 00:11:07 -07:00
|
|
|
|
|
|
|
#ifdef EVAS_CSERVE
|
|
|
|
if (evas_cserve_use_get())
|
|
|
|
{
|
|
|
|
if (evas_cserve_image_load(ie, ie->file, ie->key, &(ie->load_opts)))
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2008-04-11 17:32:30 -07:00
|
|
|
dot = strrchr (ie->file, '.');
|
2007-07-16 00:25:35 -07:00
|
|
|
if (dot)
|
2004-08-28 01:41:12 -07:00
|
|
|
{
|
2008-07-19 10:40:52 -07:00
|
|
|
for (i = 0, ++dot; i < (sizeof (loaders) / sizeof (struct ext_loader_s)); ++i)
|
|
|
|
{
|
|
|
|
if (!strcasecmp (dot, loaders[i].extention))
|
|
|
|
{
|
|
|
|
loader = loaders[i].loader;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-08-28 01:41:12 -07:00
|
|
|
}
|
2007-07-16 00:25:35 -07:00
|
|
|
|
2006-01-14 21:04:32 -08:00
|
|
|
if (loader)
|
|
|
|
{
|
|
|
|
em = evas_module_find_type(EVAS_MODULE_TYPE_IMAGE_LOADER, loader);
|
|
|
|
if (em)
|
|
|
|
{
|
|
|
|
if (evas_module_load(em))
|
|
|
|
{
|
2006-09-18 02:40:29 -07:00
|
|
|
evas_module_use(em);
|
2006-01-14 21:04:32 -08:00
|
|
|
evas_image_load_func = em->functions;
|
2008-06-03 02:09:39 -07:00
|
|
|
if (evas_image_load_func->file_head(ie, ie->file, ie->key))
|
2006-01-14 21:04:32 -08:00
|
|
|
goto ok;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-01-14 12:03:42 -08:00
|
|
|
|
2009-06-16 06:01:36 -07:00
|
|
|
/* FIXME: We don't try not loaded module yet, changed behaviour with previous one. */
|
|
|
|
evas_module_foreach_image_loader(_evas_image_foreach_loader, ie);
|
|
|
|
if (ie->info.module) return 0;
|
2006-01-14 22:21:05 -08:00
|
|
|
|
2007-07-16 00:25:35 -07:00
|
|
|
return -1;
|
|
|
|
|
2009-05-01 00:11:07 -07:00
|
|
|
ok:
|
2008-06-03 02:09:39 -07:00
|
|
|
ie->info.module = (void*) em;
|
|
|
|
ie->info.loader = (void*) evas_image_load_func;
|
|
|
|
evas_module_ref((Evas_Module*) ie->info.module);
|
2007-07-16 00:25:35 -07:00
|
|
|
return 0;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2009-05-02 08:53:48 -07:00
|
|
|
EAPI int
|
2008-04-11 17:32:30 -07:00
|
|
|
evas_common_load_rgba_image_data_from_file(Image_Entry *ie)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2006-01-14 22:21:05 -08:00
|
|
|
Evas_Image_Load_Func *evas_image_load_func = NULL;
|
2007-07-16 00:25:35 -07:00
|
|
|
|
2008-04-11 17:32:30 -07:00
|
|
|
if (ie->flags.loaded) return -1;
|
2006-01-14 12:03:42 -08:00
|
|
|
|
2009-05-01 00:11:07 -07:00
|
|
|
#ifdef EVAS_CSERVE
|
|
|
|
if (ie->data1)
|
|
|
|
{
|
|
|
|
if (evas_cserve_image_data_load(ie))
|
|
|
|
{
|
|
|
|
RGBA_Image *im = (RGBA_Image *)ie;
|
|
|
|
Mem *mem;
|
|
|
|
|
|
|
|
mem = ie->data2;
|
|
|
|
if (mem)
|
|
|
|
{
|
|
|
|
im->image.data = mem->data + mem->offset;
|
|
|
|
im->image.no_free = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!ie->info.module) return -1;
|
|
|
|
|
2008-06-03 02:09:39 -07:00
|
|
|
evas_image_load_func = ie->info.loader;
|
|
|
|
evas_module_use((Evas_Module*) ie->info.module);
|
|
|
|
if (!evas_image_load_func->file_data(ie, ie->file, ie->key))
|
2008-04-11 17:32:30 -07:00
|
|
|
return -1;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2009-03-26 23:06:45 -07:00
|
|
|
// evas_module_unref((Evas_Module*) ie->info.module);
|
|
|
|
// ie->info.module = NULL;
|
2008-04-11 17:32:30 -07:00
|
|
|
|
|
|
|
return 0;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|