2008-11-05 09:21:04 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2015-03-17 00:50:21 -07:00
|
|
|
# include "config.h"
|
2008-11-05 09:21:04 -08:00
|
|
|
#endif
|
2006-10-27 20:02:23 -07:00
|
|
|
|
2015-03-17 00:50:21 -07:00
|
|
|
#include <Emile.h>
|
2006-01-14 12:03:42 -08:00
|
|
|
|
2015-03-17 00:50:21 -07:00
|
|
|
#include "Evas_Loader.h"
|
2006-01-14 12:03:42 -08:00
|
|
|
|
2013-05-06 03:01:35 -07:00
|
|
|
typedef struct _Evas_Loader_Internal Evas_Loader_Internal;
|
|
|
|
struct _Evas_Loader_Internal
|
|
|
|
{
|
2015-03-17 00:50:21 -07:00
|
|
|
Emile_Image *image;
|
2006-01-14 12:03:42 -08:00
|
|
|
|
2015-03-17 00:50:21 -07:00
|
|
|
Eina_Rectangle region;
|
2011-06-07 06:34:18 -07:00
|
|
|
};
|
|
|
|
|
2015-03-17 00:50:21 -07:00
|
|
|
static void *
|
|
|
|
evas_image_load_file_open_jpeg(Eina_File *f, Eina_Stringshare *key EINA_UNUSED,
|
|
|
|
Evas_Image_Load_Opts *opts,
|
|
|
|
Evas_Image_Animated *animated EINA_UNUSED,
|
|
|
|
int *error)
|
2006-01-14 12:03:42 -08:00
|
|
|
{
|
2015-03-17 00:50:21 -07:00
|
|
|
Evas_Loader_Internal *loader;
|
|
|
|
Emile_Image *image;
|
|
|
|
Emile_Image_Load_Error image_error;
|
2011-09-29 02:02:30 -07:00
|
|
|
|
2017-01-01 05:15:24 -08:00
|
|
|
image = emile_image_jpeg_file_open(f, opts ? &(opts->emile) : NULL,
|
|
|
|
NULL, &image_error);
|
2015-03-17 00:50:21 -07:00
|
|
|
if (!image)
|
2006-01-14 12:03:42 -08:00
|
|
|
{
|
2015-03-17 00:50:21 -07:00
|
|
|
*error = image_error;
|
|
|
|
return NULL;
|
2006-01-14 12:03:42 -08:00
|
|
|
}
|
2011-06-07 06:34:18 -07:00
|
|
|
|
2015-03-17 00:50:21 -07:00
|
|
|
loader = calloc(1, sizeof (Evas_Loader_Internal));
|
|
|
|
if (!loader)
|
2011-06-07 06:34:18 -07:00
|
|
|
{
|
|
|
|
*error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
|
2015-03-17 00:50:21 -07:00
|
|
|
return NULL;
|
2009-05-05 14:48:50 -07:00
|
|
|
}
|
|
|
|
|
2015-03-17 00:50:21 -07:00
|
|
|
loader->image = image;
|
2017-01-01 05:15:24 -08:00
|
|
|
if (opts && (opts->emile.region.w > 0) && (opts->emile.region.h > 0))
|
2006-01-14 12:03:42 -08:00
|
|
|
{
|
2015-03-17 00:50:21 -07:00
|
|
|
EINA_RECTANGLE_SET(&loader->region,
|
2017-01-01 05:15:24 -08:00
|
|
|
opts->emile.region.x,
|
|
|
|
opts->emile.region.y,
|
|
|
|
opts->emile.region.w,
|
|
|
|
opts->emile.region.h);
|
2011-09-29 02:02:30 -07:00
|
|
|
}
|
|
|
|
else
|
2006-01-14 12:03:42 -08:00
|
|
|
{
|
2015-03-17 00:50:21 -07:00
|
|
|
EINA_RECTANGLE_SET(&loader->region,
|
|
|
|
0, 0,
|
|
|
|
-1, -1);
|
2006-01-14 12:03:42 -08:00
|
|
|
}
|
2013-05-06 03:01:35 -07:00
|
|
|
|
|
|
|
return loader;
|
|
|
|
}
|
|
|
|
|
2015-03-17 00:50:21 -07:00
|
|
|
|
2013-05-06 03:01:35 -07:00
|
|
|
static void
|
|
|
|
evas_image_load_file_close_jpeg(void *loader_data)
|
|
|
|
{
|
2015-03-17 00:50:21 -07:00
|
|
|
Evas_Loader_Internal *loader = loader_data;
|
|
|
|
|
|
|
|
emile_image_close(loader->image);
|
|
|
|
free(loader);
|
2013-05-06 03:01:35 -07:00
|
|
|
}
|
|
|
|
|
2009-12-22 15:11:57 -08:00
|
|
|
static Eina_Bool
|
2013-05-06 03:01:35 -07:00
|
|
|
evas_image_load_file_head_jpeg(void *loader_data,
|
2019-05-31 11:57:53 -07:00
|
|
|
Emile_Image_Property *prop,
|
2015-03-17 00:50:21 -07:00
|
|
|
int *error)
|
2006-01-14 12:03:42 -08:00
|
|
|
{
|
2013-05-06 03:01:35 -07:00
|
|
|
Evas_Loader_Internal *loader = loader_data;
|
2015-03-17 00:50:21 -07:00
|
|
|
Emile_Image_Load_Error image_error;
|
|
|
|
Eina_Bool ret;
|
2011-06-07 06:34:18 -07:00
|
|
|
|
2015-03-17 00:50:21 -07:00
|
|
|
ret = emile_image_head(loader->image,
|
2015-10-28 23:30:16 -07:00
|
|
|
prop, sizeof (*prop),
|
2015-03-17 00:50:21 -07:00
|
|
|
&image_error);
|
|
|
|
*error = image_error;
|
2011-06-07 06:34:18 -07:00
|
|
|
|
2015-03-17 00:50:21 -07:00
|
|
|
return ret;
|
2006-01-14 12:03:42 -08:00
|
|
|
}
|
|
|
|
|
2016-12-06 16:23:59 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_evas_image_load_jpeg_cancelled(void *data EINA_UNUSED,
|
|
|
|
Emile_Image *image EINA_UNUSED,
|
|
|
|
Emile_Action action EINA_UNUSED)
|
|
|
|
{
|
|
|
|
return evas_module_task_cancelled();
|
|
|
|
}
|
|
|
|
|
2015-03-17 00:50:21 -07:00
|
|
|
Eina_Bool
|
2013-05-06 03:01:35 -07:00
|
|
|
evas_image_load_file_data_jpeg(void *loader_data,
|
2019-05-31 11:57:53 -07:00
|
|
|
Emile_Image_Property *prop,
|
2015-03-17 00:50:21 -07:00
|
|
|
void *pixels,
|
|
|
|
int *error)
|
2006-01-14 12:03:42 -08:00
|
|
|
{
|
2013-05-06 03:01:35 -07:00
|
|
|
Evas_Loader_Internal *loader = loader_data;
|
2015-03-17 00:50:21 -07:00
|
|
|
Emile_Image_Load_Error image_error;
|
|
|
|
Eina_Bool ret;
|
2011-06-07 06:34:18 -07:00
|
|
|
|
2017-02-27 10:13:30 -08:00
|
|
|
emile_image_callback_set(loader->image,
|
|
|
|
_evas_image_load_jpeg_cancelled,
|
|
|
|
EMILE_ACTION_CANCELLED, NULL);
|
2015-03-17 00:50:21 -07:00
|
|
|
ret = emile_image_data(loader->image,
|
2015-10-28 23:30:16 -07:00
|
|
|
prop, sizeof (*prop),
|
2015-03-17 00:50:21 -07:00
|
|
|
pixels,
|
|
|
|
&image_error);
|
|
|
|
*error = image_error;
|
|
|
|
return ret;
|
2006-01-14 12:03:42 -08:00
|
|
|
}
|
|
|
|
|
2015-03-17 00:50:21 -07:00
|
|
|
Evas_Image_Load_Func evas_image_load_jpeg_func =
|
2013-05-02 01:17:42 -07:00
|
|
|
{
|
2019-05-31 10:43:32 -07:00
|
|
|
EVAS_IMAGE_LOAD_VERSION,
|
2013-05-06 03:01:35 -07:00
|
|
|
evas_image_load_file_open_jpeg,
|
|
|
|
evas_image_load_file_close_jpeg,
|
2019-05-31 11:57:53 -07:00
|
|
|
(void*) evas_image_load_file_head_jpeg,
|
|
|
|
NULL,
|
|
|
|
(void*) evas_image_load_file_data_jpeg,
|
2013-05-02 01:17:42 -07:00
|
|
|
NULL,
|
2013-05-06 18:50:57 -07:00
|
|
|
EINA_TRUE,
|
2015-04-17 01:09:51 -07:00
|
|
|
EINA_TRUE
|
2013-05-02 01:17:42 -07:00
|
|
|
};
|
|
|
|
|
2009-06-16 06:01:36 -07:00
|
|
|
static int
|
2006-09-06 00:28:46 -07:00
|
|
|
module_open(Evas_Module *em)
|
2006-01-14 12:03:42 -08:00
|
|
|
{
|
|
|
|
if (!em) return 0;
|
|
|
|
em->functions = (void *)(&evas_image_load_jpeg_func);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-06-16 06:01:36 -07:00
|
|
|
static void
|
2012-11-04 03:51:42 -08:00
|
|
|
module_close(Evas_Module *em EINA_UNUSED)
|
2006-01-14 12:03:42 -08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-06-16 06:01:36 -07:00
|
|
|
static Evas_Module_Api evas_modapi =
|
2006-01-14 12:03:42 -08:00
|
|
|
{
|
|
|
|
EVAS_MODULE_API_VERSION,
|
2009-06-16 06:01:36 -07:00
|
|
|
"jpeg",
|
|
|
|
"none",
|
|
|
|
{
|
|
|
|
module_open,
|
|
|
|
module_close
|
|
|
|
}
|
2006-01-14 12:03:42 -08:00
|
|
|
};
|
2009-06-16 06:01:36 -07:00
|
|
|
|
|
|
|
EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_IMAGE_LOADER, image_loader, jpeg);
|
|
|
|
|
|
|
|
#ifndef EVAS_STATIC_BUILD_JPEG
|
|
|
|
EVAS_EINA_MODULE_DEFINE(image_loader, jpeg);
|
|
|
|
#endif
|