2011-03-11 07:07:25 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_EVIL
|
|
|
|
# include <Evil.h>
|
|
|
|
#endif
|
|
|
|
|
2013-06-20 03:53:29 -07:00
|
|
|
#include "evas_common_private.h"
|
2011-03-11 07:07:25 -08:00
|
|
|
#include "evas_private.h"
|
|
|
|
|
2013-06-27 00:44:58 -07:00
|
|
|
static int _evas_loader_ico_log_dom = -1;
|
|
|
|
|
|
|
|
#ifdef ERR
|
|
|
|
# undef ERR
|
|
|
|
#endif
|
|
|
|
#define ERR(...) EINA_LOG_DOM_ERR(_evas_loader_ico_log_dom, __VA_ARGS__)
|
|
|
|
|
2013-05-06 03:01:35 -07:00
|
|
|
typedef struct _Evas_Loader_Internal Evas_Loader_Internal;
|
|
|
|
struct _Evas_Loader_Internal
|
|
|
|
{
|
|
|
|
Eina_File *f;
|
|
|
|
const char *key;
|
|
|
|
Evas_Image_Load_Opts *opts;
|
|
|
|
};
|
|
|
|
|
2011-12-12 09:48:53 -08:00
|
|
|
static Eina_Bool
|
|
|
|
read_ushort(unsigned char *map, size_t length, size_t *position, unsigned short *ret)
|
2011-03-11 07:07:25 -08:00
|
|
|
{
|
|
|
|
unsigned char b[2];
|
2011-12-12 09:48:53 -08:00
|
|
|
|
|
|
|
if (*position + 2 > length) return EINA_FALSE;
|
|
|
|
b[0] = map[(*position)++];
|
|
|
|
b[1] = map[(*position)++];
|
2011-03-11 07:07:25 -08:00
|
|
|
*ret = (b[1] << 8) | b[0];
|
2011-12-12 09:48:53 -08:00
|
|
|
return EINA_TRUE;
|
2011-03-11 07:07:25 -08:00
|
|
|
}
|
|
|
|
|
2011-12-12 09:48:53 -08:00
|
|
|
static Eina_Bool
|
|
|
|
read_uint(unsigned char *map, size_t length, size_t *position, unsigned int *ret)
|
2011-03-11 07:07:25 -08:00
|
|
|
{
|
2011-12-12 09:48:53 -08:00
|
|
|
unsigned char b[4];
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (*position + 4 > length) return EINA_FALSE;
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
b[i] = map[(*position)++];
|
2011-03-11 07:07:25 -08:00
|
|
|
*ret = ARGB_JOIN(b[3], b[2], b[1], b[0]);
|
2011-12-12 09:48:53 -08:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
read_uchar(unsigned char *map, size_t length, size_t *position, unsigned char *ret)
|
|
|
|
{
|
|
|
|
if (*position + 1 > length) return EINA_FALSE;
|
|
|
|
*ret = map[(*position)++];
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
read_mem(unsigned char *map, size_t length, size_t *position, void *buffer, int size)
|
|
|
|
{
|
|
|
|
if (*position + size > length) return EINA_FALSE;
|
|
|
|
memcpy(buffer, map + *position, size);
|
|
|
|
*position += size;
|
|
|
|
return EINA_TRUE;
|
2011-03-11 07:07:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2011-12-12 09:48:53 -08:00
|
|
|
SMALLEST,
|
|
|
|
BIGGEST,
|
|
|
|
SMALLER,
|
2011-03-11 07:07:25 -08:00
|
|
|
BIGGER
|
|
|
|
};
|
|
|
|
|
2011-03-12 20:41:30 -08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
ICON = 1,
|
|
|
|
CURSOR = 2
|
|
|
|
};
|
|
|
|
|
2013-05-06 03:01:35 -07:00
|
|
|
static void *
|
|
|
|
evas_image_load_file_open_ico(Eina_File *f, const char *key,
|
|
|
|
Evas_Image_Load_Opts *opts,
|
|
|
|
Evas_Image_Animated *animated EINA_UNUSED,
|
|
|
|
int *error)
|
|
|
|
{
|
|
|
|
Evas_Loader_Internal *loader;
|
|
|
|
|
|
|
|
loader = calloc(1, sizeof (Evas_Loader_Internal));
|
|
|
|
if (!loader)
|
|
|
|
{
|
|
|
|
*error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
loader->f = f;
|
2013-07-01 01:41:13 -07:00
|
|
|
loader->key = eina_stringshare_add(key);
|
2013-05-06 03:01:35 -07:00
|
|
|
loader->opts = opts;
|
|
|
|
|
|
|
|
return loader;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_image_load_file_close_ico(void *loader_data)
|
|
|
|
{
|
|
|
|
Evas_Loader_Internal *loader = loader_data;
|
|
|
|
|
|
|
|
eina_stringshare_del(loader->key);
|
|
|
|
free(loader);
|
|
|
|
}
|
|
|
|
|
2011-03-11 07:07:25 -08:00
|
|
|
static Eina_Bool
|
2013-05-06 03:01:35 -07:00
|
|
|
evas_image_load_file_head_ico(void *loader_data,
|
2013-04-24 23:07:11 -07:00
|
|
|
Evas_Image_Property *prop,
|
|
|
|
int *error)
|
2011-03-11 07:07:25 -08:00
|
|
|
{
|
2013-05-06 03:01:35 -07:00
|
|
|
Evas_Loader_Internal *loader = loader_data;
|
|
|
|
Evas_Image_Load_Opts *opts;
|
|
|
|
const char *key;
|
|
|
|
Eina_File *f;
|
|
|
|
|
2011-12-12 09:48:53 -08:00
|
|
|
void *map = NULL;
|
|
|
|
size_t position = 0;
|
2011-03-11 07:07:25 -08:00
|
|
|
unsigned short word;
|
|
|
|
unsigned char byte;
|
2013-04-24 23:07:11 -07:00
|
|
|
unsigned wanted_w = 0, wanted_h = 0;
|
|
|
|
int cols, i, planes = 0,
|
2012-01-19 08:35:47 -08:00
|
|
|
bpp = 0, pdelta, search = -1, have_choice = 0,
|
2011-03-11 07:07:25 -08:00
|
|
|
hasa = 1;
|
|
|
|
unsigned int bmoffset, bmsize, fsize;
|
|
|
|
unsigned short reserved, type, count;
|
|
|
|
struct {
|
|
|
|
int pdelta;
|
|
|
|
int w, h;
|
|
|
|
int cols;
|
|
|
|
int bpp, planes;
|
|
|
|
int hot_x, hot_y;
|
|
|
|
unsigned int bmoffset, bmsize;
|
|
|
|
} chosen = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
2013-04-24 23:07:11 -07:00
|
|
|
Eina_Bool r = EINA_FALSE;
|
2011-03-11 07:07:25 -08:00
|
|
|
|
2013-05-06 03:01:35 -07:00
|
|
|
opts = loader->opts;
|
|
|
|
f = loader->f;
|
|
|
|
key = loader->key;
|
|
|
|
|
2011-03-11 07:07:25 -08:00
|
|
|
*error = EVAS_LOAD_ERROR_UNKNOWN_FORMAT;
|
2011-12-12 09:48:53 -08:00
|
|
|
fsize = eina_file_size_get(f);
|
2011-03-11 07:07:25 -08:00
|
|
|
if (fsize < (6 + 16 + 40)) goto close_file;
|
|
|
|
|
2011-12-14 01:14:27 -08:00
|
|
|
map = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
|
|
|
|
if (!map) goto close_file;
|
|
|
|
|
2011-03-11 07:07:25 -08:00
|
|
|
// key:
|
|
|
|
// NULL == highest res
|
|
|
|
// biggest == highest res
|
|
|
|
// smallest == lowest res
|
2011-12-12 09:48:53 -08:00
|
|
|
//
|
2011-03-11 07:07:25 -08:00
|
|
|
// smaller == next size SMALLER than load opts WxH (if possible)
|
|
|
|
// bigger == next size BIGGER than load opts WxH (if possible)
|
|
|
|
// more ?
|
|
|
|
|
|
|
|
search = BIGGEST;
|
2013-04-24 23:07:11 -07:00
|
|
|
if ((opts->w > 0) && (opts->h > 0))
|
2011-03-11 07:07:25 -08:00
|
|
|
{
|
2013-04-24 23:07:11 -07:00
|
|
|
wanted_w = opts->w;
|
|
|
|
wanted_h = opts->h;
|
2011-03-11 07:07:25 -08:00
|
|
|
search = SMALLER;
|
|
|
|
}
|
2011-12-12 09:48:53 -08:00
|
|
|
|
|
|
|
if (!read_ushort(map, fsize, &position, &reserved)) goto close_file;
|
|
|
|
if (!read_ushort(map, fsize, &position, &type)) goto close_file;
|
|
|
|
if (!read_ushort(map, fsize, &position, &count)) goto close_file;
|
2011-03-12 20:41:30 -08:00
|
|
|
if (!((reserved == 0) &&
|
|
|
|
((type == ICON) || (type == CURSOR)) && (count > 0)))
|
2011-03-11 07:07:25 -08:00
|
|
|
goto close_file;
|
|
|
|
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
|
|
|
|
|
|
|
|
if (key)
|
|
|
|
{
|
|
|
|
if (!strcmp(key, "biggest"))
|
|
|
|
{
|
|
|
|
wanted_w = 0;
|
|
|
|
wanted_h = 0;
|
|
|
|
search = BIGGEST;
|
|
|
|
chosen.pdelta = 0;
|
|
|
|
}
|
|
|
|
else if (!strcmp(key, "smallest"))
|
|
|
|
{
|
|
|
|
wanted_w = 1;
|
|
|
|
wanted_h = 1;
|
|
|
|
search = SMALLEST;
|
|
|
|
chosen.pdelta = 0x7fffffff;
|
|
|
|
}
|
|
|
|
else if (!strcmp(key, "smaller"))
|
|
|
|
{
|
|
|
|
chosen.pdelta = 0x7fffffff;
|
|
|
|
search = SMALLER;
|
|
|
|
}
|
|
|
|
else if (!strcmp(key, "bigger"))
|
|
|
|
{
|
|
|
|
chosen.pdelta = 0x7fffffff;
|
|
|
|
search = BIGGER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
2011-12-23 03:31:33 -08:00
|
|
|
unsigned char tw = 0, th = 0, tcols = 0;
|
|
|
|
if (!read_uchar(map, fsize, &position, &tw)) goto close_file;
|
2013-04-24 23:07:11 -07:00
|
|
|
prop->w = tw;
|
|
|
|
if (prop->w <= 0) prop->w = 256;
|
2011-12-23 03:31:33 -08:00
|
|
|
if (!read_uchar(map, fsize, &position, &th)) goto close_file;
|
2013-04-24 23:07:11 -07:00
|
|
|
prop->h = th;
|
|
|
|
if (prop->h <= 0) prop->h = 256;
|
2011-12-23 03:31:33 -08:00
|
|
|
if (!read_uchar(map, fsize, &position, &tcols)) goto close_file;
|
|
|
|
cols = tcols;
|
2011-03-11 07:07:25 -08:00
|
|
|
if (cols <= 0) cols = 256;
|
2011-12-12 09:48:53 -08:00
|
|
|
if (!read_uchar(map, fsize, &position, &byte)) goto close_file;
|
|
|
|
if (!read_ushort(map, fsize, &position, &word)) goto close_file;
|
2011-03-12 20:41:30 -08:00
|
|
|
if (type == CURSOR) planes = word;
|
2012-01-19 08:35:47 -08:00
|
|
|
//else hot_x = word;
|
2011-12-12 09:48:53 -08:00
|
|
|
if (!read_ushort(map, fsize, &position, &word)) goto close_file;
|
2011-03-12 20:41:30 -08:00
|
|
|
if (type == CURSOR) bpp = word;
|
2012-01-19 08:35:47 -08:00
|
|
|
//else hot_y = word;
|
2011-12-12 09:48:53 -08:00
|
|
|
if (!read_uint(map, fsize, &position, &bmsize)) goto close_file;
|
|
|
|
if (!read_uint(map, fsize, &position, &bmoffset)) goto close_file;
|
2011-03-11 07:07:25 -08:00
|
|
|
if ((bmsize <= 0) || (bmoffset <= 0) || (bmoffset >= fsize)) goto close_file;
|
|
|
|
if (search == BIGGEST)
|
|
|
|
{
|
2013-04-24 23:07:11 -07:00
|
|
|
pdelta = prop->w * prop->h;
|
2011-03-11 07:07:25 -08:00
|
|
|
if ((!have_choice) ||
|
|
|
|
((pdelta >= chosen.pdelta) &&
|
|
|
|
(((bpp >= 3) && (bpp >= chosen.bpp)) ||
|
|
|
|
((bpp < 3) && (cols >= chosen.cols)))))
|
|
|
|
{
|
|
|
|
have_choice = 1;
|
|
|
|
chosen.pdelta = pdelta;
|
2013-04-24 23:07:11 -07:00
|
|
|
chosen.w = prop->w;
|
|
|
|
chosen.h = prop->h;
|
2011-03-11 07:07:25 -08:00
|
|
|
chosen.cols = cols;
|
|
|
|
chosen.bpp = bpp;
|
|
|
|
chosen.planes = planes;
|
|
|
|
chosen.bmsize = bmsize;
|
|
|
|
chosen.bmoffset = bmoffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (search == SMALLEST)
|
|
|
|
{
|
2013-04-24 23:07:11 -07:00
|
|
|
pdelta = prop->w * prop->h;
|
2011-03-11 07:07:25 -08:00
|
|
|
if ((!have_choice) ||
|
|
|
|
((pdelta <= chosen.pdelta) &&
|
|
|
|
(((bpp >= 3) && (bpp >= chosen.bpp)) ||
|
|
|
|
((bpp < 3) && (cols >= chosen.cols)))))
|
|
|
|
{
|
|
|
|
have_choice = 1;
|
|
|
|
chosen.pdelta = pdelta;
|
2013-04-24 23:07:11 -07:00
|
|
|
chosen.w = prop->w;
|
|
|
|
chosen.h = prop->h;
|
2011-03-11 07:07:25 -08:00
|
|
|
chosen.cols = cols;
|
|
|
|
chosen.bpp = bpp;
|
|
|
|
chosen.planes = planes;
|
|
|
|
chosen.bmsize = bmsize;
|
|
|
|
chosen.bmoffset = bmoffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (search == SMALLER)
|
|
|
|
{
|
2013-04-24 23:07:11 -07:00
|
|
|
pdelta = (wanted_w * wanted_h) - (prop->w * prop->h);
|
2011-03-11 07:07:25 -08:00
|
|
|
if ((!have_choice) ||
|
2013-04-24 23:07:11 -07:00
|
|
|
((prop->w <= wanted_w) && (prop->h <= wanted_h) &&
|
2011-03-11 07:07:25 -08:00
|
|
|
(pdelta <= chosen.pdelta) &&
|
|
|
|
(((bpp >= 3) && (bpp >= chosen.bpp)) ||
|
|
|
|
((bpp < 3) && (cols >= chosen.cols)))))
|
|
|
|
{
|
|
|
|
have_choice = 1;
|
|
|
|
if (pdelta < 0) pdelta = 0x7fffffff;
|
|
|
|
chosen.pdelta = pdelta;
|
2013-04-24 23:07:11 -07:00
|
|
|
chosen.w = prop->w;
|
|
|
|
chosen.h = prop->h;
|
2011-03-11 07:07:25 -08:00
|
|
|
chosen.cols = cols;
|
|
|
|
chosen.bpp = bpp;
|
|
|
|
chosen.planes = planes;
|
|
|
|
chosen.bmsize = bmsize;
|
|
|
|
chosen.bmoffset = bmoffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (search == BIGGER)
|
|
|
|
{
|
2013-04-24 23:07:11 -07:00
|
|
|
pdelta = (prop->w * prop->h) - (wanted_w * wanted_h);
|
2011-03-11 07:07:25 -08:00
|
|
|
if ((!have_choice) ||
|
2013-04-24 23:07:11 -07:00
|
|
|
((prop->w >= wanted_w) && (prop->h >= wanted_h) &&
|
2011-03-11 07:07:25 -08:00
|
|
|
(pdelta <= chosen.pdelta) &&
|
|
|
|
(((bpp >= 3) && (bpp >= chosen.bpp)) ||
|
|
|
|
((bpp < 3) && (cols >= chosen.cols)))))
|
|
|
|
{
|
|
|
|
have_choice = 1;
|
|
|
|
if (pdelta < 0) pdelta = 0x7fffffff;
|
|
|
|
chosen.pdelta = pdelta;
|
2013-04-24 23:07:11 -07:00
|
|
|
chosen.w = prop->w;
|
|
|
|
chosen.h = prop->h;
|
2011-03-11 07:07:25 -08:00
|
|
|
chosen.cols = cols;
|
|
|
|
chosen.bpp = bpp;
|
|
|
|
chosen.planes = planes;
|
|
|
|
chosen.bmsize = bmsize;
|
|
|
|
chosen.bmoffset = bmoffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (chosen.bmoffset == 0) goto close_file;
|
2011-12-12 09:48:53 -08:00
|
|
|
position = chosen.bmoffset;
|
2011-03-11 07:07:25 -08:00
|
|
|
|
2013-04-24 23:07:11 -07:00
|
|
|
prop->w = chosen.w;
|
|
|
|
prop->h = chosen.h;
|
|
|
|
if ((prop->w > 256) || (prop->h > 256)) goto close_file;
|
|
|
|
if ((prop->w < 1) || (prop->h < 1) ||
|
|
|
|
(prop->w > IMG_MAX_SIZE) || (prop->h > IMG_MAX_SIZE) ||
|
|
|
|
IMG_TOO_BIG(prop->w, prop->h))
|
2011-03-11 07:07:25 -08:00
|
|
|
{
|
2013-04-24 23:07:11 -07:00
|
|
|
if (IMG_TOO_BIG(prop->w, prop->h))
|
2011-03-11 07:07:25 -08:00
|
|
|
*error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
|
|
|
|
else
|
|
|
|
*error = EVAS_LOAD_ERROR_GENERIC;
|
|
|
|
goto close_file;
|
|
|
|
}
|
|
|
|
|
2013-04-24 23:07:11 -07:00
|
|
|
if (hasa) prop->alpha = 1;
|
2011-12-12 09:48:53 -08:00
|
|
|
|
2011-03-11 07:07:25 -08:00
|
|
|
*error = EVAS_LOAD_ERROR_NONE;
|
2013-04-24 23:07:11 -07:00
|
|
|
r = EINA_TRUE;
|
2011-03-11 07:07:25 -08:00
|
|
|
|
|
|
|
close_file:
|
2011-12-12 09:48:53 -08:00
|
|
|
if (map) eina_file_map_free(f, map);
|
2013-04-24 23:07:11 -07:00
|
|
|
|
|
|
|
return r;
|
2011-03-11 07:07:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2013-05-06 03:01:35 -07:00
|
|
|
evas_image_load_file_data_ico(void *loader_data,
|
|
|
|
Evas_Image_Property *prop,
|
|
|
|
void *pixels,
|
2013-05-02 01:17:42 -07:00
|
|
|
int *error)
|
2011-03-11 07:07:25 -08:00
|
|
|
{
|
2013-05-06 03:01:35 -07:00
|
|
|
Evas_Loader_Internal *loader = loader_data;
|
|
|
|
Evas_Image_Load_Opts *opts;
|
|
|
|
const char *key;
|
|
|
|
Eina_File *f;
|
|
|
|
|
2011-12-12 09:48:53 -08:00
|
|
|
void *map = NULL;
|
|
|
|
size_t position = 0;
|
2011-03-11 07:07:25 -08:00
|
|
|
unsigned short word;
|
|
|
|
unsigned char byte;
|
|
|
|
unsigned int dword;
|
|
|
|
int wanted_w = 0, wanted_h = 0, w, h, cols, i, planes = 0,
|
2012-01-19 08:35:47 -08:00
|
|
|
bpp = 0, pdelta, search = -1, have_choice = 0,
|
2011-03-12 20:41:30 -08:00
|
|
|
stride, pstride, j, right_way_up = 0, diff_size = 0, cols2;
|
2012-01-19 08:35:47 -08:00
|
|
|
unsigned int bmoffset, bmsize, bitcount, fsize,
|
|
|
|
*pal, *surface, *pix, none_zero_alpha = 0;
|
|
|
|
unsigned short reserved, type, count;
|
2011-03-11 07:07:25 -08:00
|
|
|
unsigned char *maskbuf, *pixbuf, *p;
|
|
|
|
struct {
|
|
|
|
int pdelta;
|
|
|
|
int w, h;
|
|
|
|
int cols;
|
|
|
|
int bpp, planes;
|
|
|
|
int hot_x, hot_y;
|
|
|
|
unsigned int bmoffset, bmsize;
|
|
|
|
} chosen = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
2013-05-02 01:17:42 -07:00
|
|
|
Eina_Bool res = EINA_FALSE;
|
2011-03-11 07:07:25 -08:00
|
|
|
|
2013-05-06 03:01:35 -07:00
|
|
|
opts = loader->opts;
|
|
|
|
key = loader->key;
|
|
|
|
f = loader->f;
|
|
|
|
|
2011-03-11 07:07:25 -08:00
|
|
|
*error = EVAS_LOAD_ERROR_UNKNOWN_FORMAT;
|
2011-12-12 09:48:53 -08:00
|
|
|
fsize = eina_file_size_get(f);
|
2011-03-11 07:07:25 -08:00
|
|
|
if (fsize < (6 + 16 + 40)) goto close_file;
|
|
|
|
|
2011-12-14 01:14:27 -08:00
|
|
|
map = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
|
|
|
|
if (!map) goto close_file;
|
|
|
|
|
2011-03-11 07:07:25 -08:00
|
|
|
// key:
|
|
|
|
// NULL == highest res
|
|
|
|
// biggest == highest res
|
|
|
|
// smallest == lowest res
|
|
|
|
//
|
|
|
|
// smaller == next size SMALLER than load opts WxH (if possible)
|
|
|
|
// bigger == next size BIGGER than load opts WxH (if possible)
|
|
|
|
// more ?
|
|
|
|
|
|
|
|
search = BIGGEST;
|
2013-05-02 01:17:42 -07:00
|
|
|
if ((opts->w > 0) && (opts->h > 0))
|
2011-03-11 07:07:25 -08:00
|
|
|
{
|
2013-05-02 01:17:42 -07:00
|
|
|
wanted_w = opts->w;
|
|
|
|
wanted_h = opts->h;
|
2011-03-11 07:07:25 -08:00
|
|
|
search = SMALLER;
|
|
|
|
}
|
2011-12-12 09:48:53 -08:00
|
|
|
|
|
|
|
if (!read_ushort(map, fsize, &position, &reserved)) goto close_file;
|
|
|
|
if (!read_ushort(map, fsize, &position, &type)) goto close_file;
|
|
|
|
if (!read_ushort(map, fsize, &position, &count)) goto close_file;
|
|
|
|
if (!((reserved == 0) &&
|
2011-03-12 20:41:30 -08:00
|
|
|
((type == ICON) || (type == CURSOR)) && (count > 0)))
|
2011-03-11 07:07:25 -08:00
|
|
|
goto close_file;
|
|
|
|
*error = EVAS_LOAD_ERROR_CORRUPT_FILE;
|
|
|
|
|
|
|
|
if (key)
|
|
|
|
{
|
|
|
|
if (!strcmp(key, "biggest"))
|
|
|
|
{
|
|
|
|
wanted_w = 0;
|
|
|
|
wanted_h = 0;
|
|
|
|
search = BIGGEST;
|
|
|
|
chosen.pdelta = 0;
|
|
|
|
}
|
|
|
|
else if (!strcmp(key, "smallest"))
|
|
|
|
{
|
|
|
|
wanted_w = 1;
|
|
|
|
wanted_h = 1;
|
|
|
|
search = SMALLEST;
|
|
|
|
chosen.pdelta = 0x7fffffff;
|
|
|
|
}
|
|
|
|
else if (!strcmp(key, "smaller"))
|
|
|
|
{
|
|
|
|
chosen.pdelta = 0x7fffffff;
|
|
|
|
search = SMALLER;
|
|
|
|
}
|
|
|
|
else if (!strcmp(key, "bigger"))
|
|
|
|
{
|
|
|
|
chosen.pdelta = 0x7fffffff;
|
|
|
|
search = BIGGER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
2011-12-23 03:31:33 -08:00
|
|
|
unsigned char tw = 0, th = 0, tcols = 0;
|
|
|
|
if (!read_uchar(map, fsize, &position, &tw)) goto close_file;
|
2011-12-23 18:42:27 -08:00
|
|
|
w = tw;
|
2011-03-11 07:07:25 -08:00
|
|
|
if (w <= 0) w = 256;
|
2011-12-23 03:31:33 -08:00
|
|
|
if (!read_uchar(map, fsize, &position, &th)) goto close_file;
|
|
|
|
h = th;
|
2011-03-11 07:07:25 -08:00
|
|
|
if (h <= 0) h = 256;
|
2011-12-23 03:31:33 -08:00
|
|
|
if (!read_uchar(map, fsize, &position, &tcols)) goto close_file;
|
|
|
|
cols = tcols;
|
2011-03-11 07:07:25 -08:00
|
|
|
if (cols <= 0) cols = 256;
|
2011-12-12 09:48:53 -08:00
|
|
|
if (!read_uchar(map, fsize, &position, &byte)) goto close_file;
|
|
|
|
if (!read_ushort(map, fsize, &position, &word)) goto close_file;
|
2011-03-11 07:07:25 -08:00
|
|
|
if (type == 1) planes = word;
|
2012-01-19 08:35:47 -08:00
|
|
|
//else hot_x = word;
|
2011-12-12 09:48:53 -08:00
|
|
|
if (!read_ushort(map, fsize, &position, &word)) goto close_file;
|
2011-03-11 07:07:25 -08:00
|
|
|
if (type == 1) bpp = word;
|
2012-01-19 08:35:47 -08:00
|
|
|
//else hot_y = word;
|
2011-12-12 09:48:53 -08:00
|
|
|
if (!read_uint(map, fsize, &position, &bmsize)) goto close_file;
|
|
|
|
if (!read_uint(map, fsize, &position, &bmoffset)) goto close_file;
|
2011-03-11 07:07:25 -08:00
|
|
|
if ((bmsize <= 0) || (bmoffset <= 0) || (bmoffset >= fsize)) goto close_file;
|
|
|
|
if (search == BIGGEST)
|
|
|
|
{
|
|
|
|
pdelta = w * h;
|
|
|
|
if ((!have_choice) ||
|
|
|
|
((pdelta >= chosen.pdelta) &&
|
|
|
|
(((bpp >= 3) && (bpp >= chosen.bpp)) ||
|
|
|
|
((bpp < 3) && (cols >= chosen.cols)))))
|
|
|
|
{
|
|
|
|
have_choice = 1;
|
|
|
|
chosen.pdelta = pdelta;
|
|
|
|
chosen.w = w;
|
|
|
|
chosen.h = h;
|
|
|
|
chosen.cols = cols;
|
|
|
|
chosen.bpp = bpp;
|
|
|
|
chosen.planes = planes;
|
|
|
|
chosen.bmsize = bmsize;
|
|
|
|
chosen.bmoffset = bmoffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (search == SMALLEST)
|
|
|
|
{
|
|
|
|
pdelta = w * h;
|
|
|
|
if ((!have_choice) ||
|
|
|
|
((pdelta <= chosen.pdelta) &&
|
|
|
|
(((bpp >= 3) && (bpp >= chosen.bpp)) ||
|
|
|
|
((bpp < 3) && (cols >= chosen.cols)))))
|
|
|
|
{
|
|
|
|
have_choice = 1;
|
|
|
|
chosen.pdelta = pdelta;
|
|
|
|
chosen.w = w;
|
|
|
|
chosen.h = h;
|
|
|
|
chosen.cols = cols;
|
|
|
|
chosen.bpp = bpp;
|
|
|
|
chosen.planes = planes;
|
|
|
|
chosen.bmsize = bmsize;
|
|
|
|
chosen.bmoffset = bmoffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (search == SMALLER)
|
|
|
|
{
|
|
|
|
pdelta = (wanted_w * wanted_h) - (w * h);
|
|
|
|
if ((!have_choice) ||
|
|
|
|
((w <= wanted_w) && (h <= wanted_h) &&
|
|
|
|
(pdelta <= chosen.pdelta) &&
|
|
|
|
(((bpp >= 3) && (bpp >= chosen.bpp)) ||
|
|
|
|
((bpp < 3) && (cols >= chosen.cols)))))
|
|
|
|
{
|
|
|
|
have_choice = 1;
|
|
|
|
if (pdelta < 0) pdelta = 0x7fffffff;
|
|
|
|
chosen.pdelta = pdelta;
|
|
|
|
chosen.w = w;
|
|
|
|
chosen.h = h;
|
|
|
|
chosen.cols = cols;
|
|
|
|
chosen.bpp = bpp;
|
|
|
|
chosen.planes = planes;
|
|
|
|
chosen.bmsize = bmsize;
|
|
|
|
chosen.bmoffset = bmoffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (search == BIGGER)
|
|
|
|
{
|
|
|
|
pdelta = (w * h) - (wanted_w * wanted_h);
|
|
|
|
if ((!have_choice) ||
|
|
|
|
((w >= wanted_w) && (h >= wanted_h) &&
|
|
|
|
(pdelta <= chosen.pdelta) &&
|
|
|
|
(((bpp >= 3) && (bpp >= chosen.bpp)) ||
|
|
|
|
((bpp < 3) && (cols >= chosen.cols)))))
|
|
|
|
{
|
|
|
|
have_choice = 1;
|
|
|
|
if (pdelta < 0) pdelta = 0x7fffffff;
|
|
|
|
chosen.pdelta = pdelta;
|
|
|
|
chosen.w = w;
|
|
|
|
chosen.h = h;
|
|
|
|
chosen.cols = cols;
|
|
|
|
chosen.bpp = bpp;
|
|
|
|
chosen.planes = planes;
|
|
|
|
chosen.bmsize = bmsize;
|
|
|
|
chosen.bmoffset = bmoffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (chosen.bmoffset == 0) goto close_file;
|
2011-12-12 09:48:53 -08:00
|
|
|
position = chosen.bmoffset;
|
2011-03-11 07:07:25 -08:00
|
|
|
|
|
|
|
w = chosen.w;
|
|
|
|
h = chosen.h;
|
|
|
|
cols = chosen.cols;
|
|
|
|
bpp = chosen.bpp;
|
|
|
|
// changed since we loaded header?
|
2013-05-02 01:17:42 -07:00
|
|
|
if (((int)prop->w != w) || ((int)prop->h != h)) goto close_file;
|
2011-03-11 07:07:25 -08:00
|
|
|
|
|
|
|
// read bmp header time... let's do some checking
|
2011-12-12 09:48:53 -08:00
|
|
|
if (!read_uint(map, fsize, &position, &dword)) goto close_file; // headersize - dont care
|
|
|
|
if (!read_uint(map, fsize, &position, &dword)) goto close_file; // width
|
2011-03-12 20:41:30 -08:00
|
|
|
if (dword > 0)
|
|
|
|
{
|
|
|
|
if ((int)dword != w)
|
|
|
|
{
|
|
|
|
w = dword;
|
|
|
|
diff_size = 1;
|
|
|
|
}
|
|
|
|
}
|
2011-12-12 09:48:53 -08:00
|
|
|
if (!read_uint(map, fsize, &position, &dword)) goto close_file; // height
|
2011-03-12 20:41:30 -08:00
|
|
|
if (dword > 0)
|
|
|
|
{
|
|
|
|
if ((int)dword != (h * 2))
|
|
|
|
{
|
|
|
|
h = dword / 2;
|
|
|
|
diff_size = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (diff_size)
|
|
|
|
{
|
|
|
|
ERR("Broken ICO file: %s - "
|
|
|
|
" Reporting size of %ix%i in index, but bitmap is %ix%i. "
|
|
|
|
" May be expanded or cropped.",
|
2013-05-02 01:17:42 -07:00
|
|
|
eina_file_filename_get(f), prop->w, prop->h, w, h);
|
2011-03-12 20:41:30 -08:00
|
|
|
}
|
2011-12-12 09:48:53 -08:00
|
|
|
if (!read_ushort(map, fsize, &position, &word)) goto close_file; // planes
|
2012-01-19 08:35:47 -08:00
|
|
|
//planes2 = word;
|
2011-12-12 09:48:53 -08:00
|
|
|
if (!read_ushort(map, fsize, &position, &word)) goto close_file; // bitcount
|
2011-03-11 07:07:25 -08:00
|
|
|
bitcount = word;
|
2011-12-12 09:48:53 -08:00
|
|
|
if (!read_uint(map, fsize, &position, &dword)) goto close_file; // compression
|
2012-01-19 08:35:47 -08:00
|
|
|
//compression = dword;
|
2011-12-12 09:48:53 -08:00
|
|
|
if (!read_uint(map, fsize, &position, &dword)) goto close_file; // imagesize
|
2012-01-19 08:35:47 -08:00
|
|
|
//imagesize = dword;
|
2011-12-12 09:48:53 -08:00
|
|
|
if (!read_uint(map, fsize, &position, &dword)) goto close_file; // z pixels per m
|
|
|
|
if (!read_uint(map, fsize, &position, &dword)) goto close_file; // y pizels per m
|
|
|
|
if (!read_uint(map, fsize, &position, &dword)) goto close_file; // colors used
|
2012-01-19 08:35:47 -08:00
|
|
|
//colorsused = dword;
|
2011-12-12 09:48:53 -08:00
|
|
|
if (!read_uint(map, fsize, &position, &dword)) goto close_file; // colors important
|
2012-01-19 08:35:47 -08:00
|
|
|
//colorsimportant = dword;
|
2011-03-12 20:41:30 -08:00
|
|
|
|
2013-05-02 01:17:42 -07:00
|
|
|
surface = pixels;
|
|
|
|
memset(surface, 0, prop->w * prop->h * 4);
|
2011-03-12 20:41:30 -08:00
|
|
|
|
2011-03-11 07:07:25 -08:00
|
|
|
if (!((bitcount == 1) || (bitcount == 4) || (bitcount == 8) ||
|
|
|
|
(bitcount == 24) || (bitcount == 32)))
|
|
|
|
goto close_file;
|
2011-03-12 20:41:30 -08:00
|
|
|
if (bitcount <= 8)
|
|
|
|
{
|
|
|
|
cols2 = 1 << bitcount;
|
|
|
|
if (cols == 0) cols = cols2;
|
|
|
|
if (cols > cols2) cols = cols2;
|
|
|
|
if (cols > 256) cols = 256;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
cols = 0;
|
2011-03-11 07:07:25 -08:00
|
|
|
if (bitcount > 8) cols = 0;
|
2011-03-12 20:41:30 -08:00
|
|
|
|
2011-03-11 07:07:25 -08:00
|
|
|
pal = alloca(256 * 4);
|
|
|
|
for (i = 0; i < cols; i++)
|
|
|
|
{
|
|
|
|
unsigned char a, r, g, b;
|
2011-12-12 09:48:53 -08:00
|
|
|
|
|
|
|
if (!read_uchar(map, fsize, &position, &b)) goto close_file;
|
|
|
|
if (!read_uchar(map, fsize, &position, &g)) goto close_file;
|
|
|
|
if (!read_uchar(map, fsize, &position, &r)) goto close_file;
|
|
|
|
if (!read_uchar(map, fsize, &position, &a)) goto close_file;
|
2011-03-11 07:07:25 -08:00
|
|
|
a = 0xff;
|
|
|
|
pal[i] = ARGB_JOIN(a, r, g, b);
|
|
|
|
}
|
|
|
|
stride = ((w + 31) / 32);
|
|
|
|
maskbuf = alloca(stride * h);
|
|
|
|
pixbuf = alloca(stride * 32 * 4); // more than enough
|
|
|
|
if (bitcount == 1)
|
|
|
|
{
|
2011-03-12 20:41:30 -08:00
|
|
|
pstride = stride * 4;
|
2011-03-11 07:07:25 -08:00
|
|
|
for (i = 0; i < h; i++)
|
|
|
|
{
|
2013-05-02 01:17:42 -07:00
|
|
|
pix = surface + (i * w);
|
|
|
|
if (!right_way_up) pix = surface + ((h - 1 - i) * w);
|
2011-12-12 09:48:53 -08:00
|
|
|
if (!read_mem(map, fsize, &position, pixbuf, pstride)) goto close_file;
|
2011-03-11 07:07:25 -08:00
|
|
|
p = pixbuf;
|
2013-05-02 01:17:42 -07:00
|
|
|
if (i >= h) continue;
|
2011-03-11 07:07:25 -08:00
|
|
|
for (j = 0; j < w; j++)
|
|
|
|
{
|
2013-05-02 01:17:42 -07:00
|
|
|
if (j >= w) break;
|
2011-03-11 07:07:25 -08:00
|
|
|
if ((j & 0x7) == 0x0)
|
|
|
|
{
|
|
|
|
*pix = pal[*p >> 7];
|
|
|
|
}
|
|
|
|
else if ((j & 0x7) == 0x1)
|
|
|
|
{
|
|
|
|
*pix = pal[(*p >> 6) & 0x1];
|
|
|
|
}
|
|
|
|
else if ((j & 0x7) == 0x2)
|
|
|
|
{
|
|
|
|
*pix = pal[(*p >> 5) & 0x1];
|
|
|
|
}
|
|
|
|
else if ((j & 0x7) == 0x3)
|
|
|
|
{
|
|
|
|
*pix = pal[(*p >> 4) & 0x1];
|
|
|
|
}
|
|
|
|
else if ((j & 0x7) == 0x4)
|
|
|
|
{
|
|
|
|
*pix = pal[(*p >> 3) & 0x1];
|
|
|
|
}
|
|
|
|
else if ((j & 0x7) == 0x5)
|
|
|
|
{
|
|
|
|
*pix = pal[(*p >> 2) & 0x1];
|
|
|
|
}
|
|
|
|
else if ((j & 0x7) == 0x6)
|
|
|
|
{
|
|
|
|
*pix = pal[(*p >> 1) & 0x1];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*pix = pal[*p & 0x1];
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
pix++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (bitcount == 4)
|
|
|
|
{
|
|
|
|
pstride = ((w + 7) / 8) * 4;
|
|
|
|
for (i = 0; i < h; i++)
|
|
|
|
{
|
2013-05-02 01:17:42 -07:00
|
|
|
pix = surface + (i * w);
|
|
|
|
if (!right_way_up) pix = surface + ((h - 1 - i) * w);
|
2011-12-12 09:48:53 -08:00
|
|
|
if (!read_mem(map, fsize, &position, pixbuf, pstride)) goto close_file;
|
2011-03-11 07:07:25 -08:00
|
|
|
p = pixbuf;
|
2013-05-02 01:17:42 -07:00
|
|
|
if (i >= h) continue;
|
2011-03-11 07:07:25 -08:00
|
|
|
for (j = 0; j < w; j++)
|
|
|
|
{
|
2013-05-02 01:17:42 -07:00
|
|
|
if (j >= w) break;
|
2011-03-11 07:07:25 -08:00
|
|
|
if ((j & 0x1) == 0x1)
|
|
|
|
{
|
|
|
|
*pix = pal[*p & 0x0f];
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*pix = pal[*p >> 4];
|
|
|
|
}
|
|
|
|
pix++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (bitcount == 8)
|
|
|
|
{
|
|
|
|
pstride = ((w + 3) / 4) * 4;
|
|
|
|
for (i = 0; i < h; i++)
|
|
|
|
{
|
2013-05-02 01:17:42 -07:00
|
|
|
pix = surface + (i * w);
|
|
|
|
if (!right_way_up) pix = surface + ((h - 1 - i) * w);
|
2011-12-12 09:48:53 -08:00
|
|
|
if (!read_mem(map, fsize, &position, pixbuf, pstride)) goto close_file;
|
2011-03-11 07:07:25 -08:00
|
|
|
p = pixbuf;
|
2013-05-02 01:17:42 -07:00
|
|
|
if (i >= h) continue;
|
2011-03-11 07:07:25 -08:00
|
|
|
for (j = 0; j < w; j++)
|
|
|
|
{
|
2013-05-02 01:17:42 -07:00
|
|
|
if (j >= w) break;
|
2011-03-11 07:07:25 -08:00
|
|
|
*pix = pal[*p];
|
|
|
|
p++;
|
|
|
|
pix++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (bitcount == 24)
|
|
|
|
{
|
|
|
|
pstride = w * 3;
|
|
|
|
for (i = 0; i < h; i++)
|
|
|
|
{
|
2013-05-02 01:17:42 -07:00
|
|
|
pix = surface + (i * w);
|
|
|
|
if (!right_way_up) pix = surface + ((h - 1 - i) * w);
|
2011-12-12 09:48:53 -08:00
|
|
|
if (!read_mem(map, fsize, &position, pixbuf, pstride)) goto close_file;
|
2011-03-11 07:07:25 -08:00
|
|
|
p = pixbuf;
|
2013-05-02 01:17:42 -07:00
|
|
|
if (i >= h) continue;
|
2011-03-11 07:07:25 -08:00
|
|
|
for (j = 0; j < w; j++)
|
|
|
|
{
|
|
|
|
unsigned char a, r, g, b;
|
2011-12-12 09:48:53 -08:00
|
|
|
|
2013-05-02 01:17:42 -07:00
|
|
|
if (j >= w) break;
|
2011-03-11 07:07:25 -08:00
|
|
|
b = p[0];
|
|
|
|
g = p[1];
|
|
|
|
r = p[2];
|
|
|
|
p += 3;
|
|
|
|
a = 0xff;
|
|
|
|
*pix = ARGB_JOIN(a, r, g, b);
|
|
|
|
pix++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (bitcount == 32)
|
|
|
|
{
|
|
|
|
pstride = w * 4;
|
|
|
|
for (i = 0; i < h; i++)
|
|
|
|
{
|
2013-05-02 01:17:42 -07:00
|
|
|
pix = surface + (i * w);
|
|
|
|
if (!right_way_up) pix = surface + ((h - 1 - i) * w);
|
2011-12-12 09:48:53 -08:00
|
|
|
if (!read_mem(map, fsize, &position, pixbuf, pstride)) goto close_file;
|
2011-03-11 07:07:25 -08:00
|
|
|
p = pixbuf;
|
2013-05-02 01:17:42 -07:00
|
|
|
if (i >= h) continue;
|
2011-03-11 07:07:25 -08:00
|
|
|
for (j = 0; j < w; j++)
|
|
|
|
{
|
|
|
|
unsigned char a, r, g, b;
|
2011-12-12 09:48:53 -08:00
|
|
|
|
2013-05-02 01:17:42 -07:00
|
|
|
if (j >= w) break;
|
2011-03-11 07:07:25 -08:00
|
|
|
b = p[0];
|
|
|
|
g = p[1];
|
|
|
|
r = p[2];
|
|
|
|
a = p[3];
|
|
|
|
p += 4;
|
|
|
|
if (a) none_zero_alpha = 1;
|
|
|
|
*pix = ARGB_JOIN(a, r, g, b);
|
|
|
|
pix++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!none_zero_alpha)
|
|
|
|
{
|
2011-12-12 09:48:53 -08:00
|
|
|
if (!read_mem(map, fsize, &position, maskbuf, stride * 4 * h)) goto close_file;
|
2011-03-11 07:07:25 -08:00
|
|
|
// apply mask
|
|
|
|
pix = surface;
|
|
|
|
for (i = 0; i < h; i++)
|
|
|
|
{
|
|
|
|
unsigned char *m;
|
2011-12-12 09:48:53 -08:00
|
|
|
|
2013-05-02 01:17:42 -07:00
|
|
|
pix = surface + (i * w);
|
|
|
|
if (!right_way_up) pix = surface + ((h - 1 - i) * w);
|
2011-03-11 07:07:25 -08:00
|
|
|
m = maskbuf + (stride * i * 4);
|
2013-05-02 01:17:42 -07:00
|
|
|
if (i >= h) continue;
|
2011-03-11 07:07:25 -08:00
|
|
|
for (j = 0; j < w; j++)
|
|
|
|
{
|
2013-05-02 01:17:42 -07:00
|
|
|
if (j >= w) break;
|
2011-03-11 07:07:25 -08:00
|
|
|
if (*m & (1 << (7 - (j & 0x7))))
|
|
|
|
A_VAL(pix) = 0x00;
|
|
|
|
else
|
|
|
|
A_VAL(pix) = 0xff;
|
|
|
|
if ((j & 0x7) == 0x7) m++;
|
|
|
|
pix++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-12-12 09:48:53 -08:00
|
|
|
|
|
|
|
|
2013-05-02 01:17:42 -07:00
|
|
|
prop->premul = EINA_TRUE;
|
2011-03-11 07:07:25 -08:00
|
|
|
*error = EVAS_LOAD_ERROR_NONE;
|
2013-05-02 01:17:42 -07:00
|
|
|
|
|
|
|
res = EINA_TRUE;
|
2011-03-11 07:07:25 -08:00
|
|
|
|
|
|
|
close_file:
|
2011-12-23 03:31:33 -08:00
|
|
|
if (map) eina_file_map_free(f, map);
|
2013-05-02 01:17:42 -07:00
|
|
|
|
|
|
|
return res;
|
2011-03-11 07:07:25 -08:00
|
|
|
}
|
|
|
|
|
2013-05-02 01:17:42 -07:00
|
|
|
static Evas_Image_Load_Func evas_image_load_ico_func =
|
|
|
|
{
|
2013-05-06 03:01:35 -07:00
|
|
|
evas_image_load_file_open_ico,
|
|
|
|
evas_image_load_file_close_ico,
|
2013-05-02 01:17:42 -07:00
|
|
|
evas_image_load_file_head_ico,
|
|
|
|
evas_image_load_file_data_ico,
|
|
|
|
NULL,
|
2013-05-06 18:50:57 -07:00
|
|
|
EINA_TRUE,
|
2013-05-02 01:17:42 -07:00
|
|
|
EINA_FALSE
|
|
|
|
};
|
|
|
|
|
2011-03-11 07:07:25 -08:00
|
|
|
static int
|
|
|
|
module_open(Evas_Module *em)
|
|
|
|
{
|
|
|
|
if (!em) return 0;
|
2013-06-27 00:44:58 -07:00
|
|
|
_evas_loader_ico_log_dom = eina_log_domain_register
|
|
|
|
("evas-ico", EVAS_DEFAULT_LOG_COLOR);
|
|
|
|
if (_evas_loader_ico_log_dom < 0)
|
|
|
|
{
|
|
|
|
EINA_LOG_ERR("Can not create a module log domain.");
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-11 07:07:25 -08:00
|
|
|
em->functions = (void *)(&evas_image_load_ico_func);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-11-04 03:51:42 -08:00
|
|
|
module_close(Evas_Module *em EINA_UNUSED)
|
2011-03-11 07:07:25 -08:00
|
|
|
{
|
2013-06-27 00:44:58 -07:00
|
|
|
eina_log_domain_unregister(_evas_loader_ico_log_dom);
|
2011-03-11 07:07:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Module_Api evas_modapi =
|
|
|
|
{
|
|
|
|
EVAS_MODULE_API_VERSION,
|
|
|
|
"ico",
|
|
|
|
"none",
|
|
|
|
{
|
|
|
|
module_open,
|
|
|
|
module_close
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_IMAGE_LOADER, image_loader, ico);
|
|
|
|
|
|
|
|
#ifndef EVAS_STATIC_BUILD_ICO
|
|
|
|
EVAS_EINA_MODULE_DEFINE(image_loader, ico);
|
|
|
|
#endif
|