forked from enlightenment/efl
Thanks to samsung - added WBMP loader.
SVN revision: 56624
This commit is contained in:
parent
3bf3e34ff4
commit
75bb165f29
|
@ -32,3 +32,8 @@
|
||||||
|
|
||||||
* Fix lurking free bug in key grabs.
|
* Fix lurking free bug in key grabs.
|
||||||
|
|
||||||
|
|
||||||
|
2011-02-01 Carsten Haitzler (The Rasterman)
|
||||||
|
|
||||||
|
* Added WBMP loader thanks to Samsung.
|
||||||
|
|
||||||
|
|
|
@ -125,6 +125,7 @@ want_evas_image_loader_tiff="yes"
|
||||||
want_evas_image_loader_xpm="yes"
|
want_evas_image_loader_xpm="yes"
|
||||||
want_evas_image_loader_bmp="yes"
|
want_evas_image_loader_bmp="yes"
|
||||||
want_evas_image_loader_tga="yes"
|
want_evas_image_loader_tga="yes"
|
||||||
|
want_evas_image_loader_wbmp="yes"
|
||||||
|
|
||||||
want_evas_font_loader_eet="yes"
|
want_evas_font_loader_eet="yes"
|
||||||
|
|
||||||
|
@ -816,6 +817,8 @@ EVAS_CHECK_IMAGE_LOADER([BMP], [${want_evas_image_loader_bmp}])
|
||||||
|
|
||||||
EVAS_CHECK_IMAGE_LOADER([TGA], [${want_evas_image_loader_tga}])
|
EVAS_CHECK_IMAGE_LOADER([TGA], [${want_evas_image_loader_tga}])
|
||||||
|
|
||||||
|
EVAS_CHECK_IMAGE_LOADER([WBMP], [${want_evas_image_loader_wbmp}])
|
||||||
|
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
## Cpu based optimizations
|
## Cpu based optimizations
|
||||||
|
@ -1594,6 +1597,7 @@ src/modules/loaders/bmp/Makefile
|
||||||
src/modules/loaders/tga/Makefile
|
src/modules/loaders/tga/Makefile
|
||||||
src/modules/loaders/svg/Makefile
|
src/modules/loaders/svg/Makefile
|
||||||
src/modules/loaders/pmaps/Makefile
|
src/modules/loaders/pmaps/Makefile
|
||||||
|
src/modules/loaders/wbmp/Makefile
|
||||||
src/modules/savers/Makefile
|
src/modules/savers/Makefile
|
||||||
src/modules/savers/edb/Makefile
|
src/modules/savers/edb/Makefile
|
||||||
src/modules/savers/eet/Makefile
|
src/modules/savers/eet/Makefile
|
||||||
|
@ -1696,6 +1700,7 @@ echo " TIFF....................: $have_evas_image_loader_tiff"
|
||||||
echo " XPM.....................: $have_evas_image_loader_xpm"
|
echo " XPM.....................: $have_evas_image_loader_xpm"
|
||||||
echo " BMP.....................: $have_evas_image_loader_bmp"
|
echo " BMP.....................: $have_evas_image_loader_bmp"
|
||||||
echo " TGA.....................: $have_evas_image_loader_tga"
|
echo " TGA.....................: $have_evas_image_loader_tga"
|
||||||
|
echo " WBMP....................: $have_evas_image_loader_wbmp"
|
||||||
echo
|
echo
|
||||||
echo "Font Sourcing Systems:"
|
echo "Font Sourcing Systems:"
|
||||||
echo " EET.....................: $have_evas_font_loader_eet"
|
echo " EET.....................: $have_evas_font_loader_eet"
|
||||||
|
|
|
@ -348,6 +348,26 @@ fi
|
||||||
|
|
||||||
])
|
])
|
||||||
|
|
||||||
|
dnl use: EVAS_CHECK_LOADER_DEP_WBMP(loader, want_static[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||||
|
|
||||||
|
AC_DEFUN([EVAS_CHECK_LOADER_DEP_WBMP],
|
||||||
|
[
|
||||||
|
|
||||||
|
have_dep="yes"
|
||||||
|
evas_image_loader_[]$1[]_cflags=""
|
||||||
|
evas_image_loader_[]$1[]_libs=""
|
||||||
|
|
||||||
|
AC_SUBST([evas_image_loader_$1_cflags])
|
||||||
|
AC_SUBST([evas_image_loader_$1_libs])
|
||||||
|
|
||||||
|
if test "x${have_dep}" = "xyes" ; then
|
||||||
|
m4_default([$3], [:])
|
||||||
|
else
|
||||||
|
m4_default([$4], [:])
|
||||||
|
fi
|
||||||
|
|
||||||
|
])
|
||||||
|
|
||||||
dnl use: EVAS_CHECK_IMAGE_LOADER(loader, want_loader, macro)
|
dnl use: EVAS_CHECK_IMAGE_LOADER(loader, want_loader, macro)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,12 +29,13 @@ static const struct ext_loader_s loaders[] =
|
||||||
{ "ppm", "pmaps" },
|
{ "ppm", "pmaps" },
|
||||||
{ "pnm", "pmaps" },
|
{ "pnm", "pmaps" },
|
||||||
{ "bmp", "bmp" },
|
{ "bmp", "bmp" },
|
||||||
{ "tga", "tga" }
|
{ "tga", "tga" },
|
||||||
|
{ "wbmp", "wbmp" }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *loaders_name[] =
|
static const char *loaders_name[] =
|
||||||
{
|
{
|
||||||
"png", "jpeg", "eet", "xpm", "tiff", "gif", "svg", "pmaps", "edb", "bmp", "tga"
|
"png", "jpeg", "eet", "xpm", "tiff", "gif", "svg", "pmaps", "edb", "bmp", "tga", "wbmp"
|
||||||
};
|
};
|
||||||
|
|
||||||
struct evas_image_foreach_loader_data
|
struct evas_image_foreach_loader_data
|
||||||
|
|
|
@ -124,6 +124,7 @@ EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, gif);
|
||||||
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, eet);
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, eet);
|
||||||
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, edb);
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, edb);
|
||||||
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, tga);
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, tga);
|
||||||
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_loader, wbmp);
|
||||||
EVAS_EINA_STATIC_MODULE_DEFINE(image_saver, edb);
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_saver, edb);
|
||||||
EVAS_EINA_STATIC_MODULE_DEFINE(image_saver, eet);
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_saver, eet);
|
||||||
EVAS_EINA_STATIC_MODULE_DEFINE(image_saver, jpeg);
|
EVAS_EINA_STATIC_MODULE_DEFINE(image_saver, jpeg);
|
||||||
|
@ -236,6 +237,9 @@ static const struct {
|
||||||
#ifdef EVAS_STATIC_BUILD_TGA
|
#ifdef EVAS_STATIC_BUILD_TGA
|
||||||
EVAS_EINA_STATIC_MODULE_USE(image_loader, tga),
|
EVAS_EINA_STATIC_MODULE_USE(image_loader, tga),
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef EVAS_STATIC_BUILD_WBMP
|
||||||
|
EVAS_EINA_STATIC_MODULE_USE(image_loader, wbmp),
|
||||||
|
#endif
|
||||||
#ifdef EVAS_STATIC_BUILD_EDB
|
#ifdef EVAS_STATIC_BUILD_EDB
|
||||||
EVAS_EINA_STATIC_MODULE_USE(image_saver, edb),
|
EVAS_EINA_STATIC_MODULE_USE(image_saver, edb),
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -68,3 +68,9 @@ SUBDIRS += tga
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if BUILD_LOADER_WBMP
|
||||||
|
if !EVAS_STATIC_BUILD_WBMP
|
||||||
|
SUBDIRS += wbmp
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
|
||||||
|
MAINTAINERCLEANFILES = Makefile.in
|
||||||
|
|
||||||
|
AM_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/src/lib \
|
||||||
|
-I$(top_srcdir)/src/lib/include \
|
||||||
|
@FREETYPE_CFLAGS@ \
|
||||||
|
@EINA_CFLAGS@ \
|
||||||
|
@EVIL_CFLAGS@ \
|
||||||
|
@WIN32_CPPFLAGS@
|
||||||
|
|
||||||
|
if BUILD_LOADER_WBMP
|
||||||
|
if !EVAS_STATIC_BUILD_WBMP
|
||||||
|
|
||||||
|
pkgdir = $(libdir)/evas/modules/loaders/wbmp/$(MODULE_ARCH)
|
||||||
|
pkg_LTLIBRARIES = module.la
|
||||||
|
|
||||||
|
module_la_SOURCES = evas_image_load_wbmp.c
|
||||||
|
|
||||||
|
module_la_LIBADD = @EINA_LIBS@ @EVIL_LIBS@ $(top_builddir)/src/lib/libevas.la
|
||||||
|
module_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -module -avoid-version
|
||||||
|
module_la_LIBTOOLFLAGS = --tag=disable-static
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
noinst_LTLIBRARIES = libevas_loader_wbmp.la
|
||||||
|
libevas_loader_wbmp_la_SOURCES = evas_image_load_wbmp.c
|
||||||
|
libevas_loader_wbmp_la_LIBADD =
|
||||||
|
|
||||||
|
endif
|
||||||
|
endif
|
|
@ -0,0 +1,162 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_EVIL
|
||||||
|
# include <Evil.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "evas_common.h"
|
||||||
|
#include "evas_private.h"
|
||||||
|
|
||||||
|
static Eina_Bool evas_image_load_file_head_wbmp(Image_Entry *ie, const char *file, const char *key, int *error) EINA_ARG_NONNULL(1, 2, 4);
|
||||||
|
static Eina_Bool evas_image_load_file_data_wbmp(Image_Entry *ie, const char *file, const char *key, int *error) EINA_ARG_NONNULL(1, 2, 4);
|
||||||
|
|
||||||
|
static Evas_Image_Load_Func evas_image_load_wbmp_func =
|
||||||
|
{
|
||||||
|
EINA_TRUE,
|
||||||
|
evas_image_load_file_head_wbmp,
|
||||||
|
evas_image_load_file_data_wbmp
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
read_mb(unsigned int *data, FILE * f)
|
||||||
|
{
|
||||||
|
int ac = 0, ct;
|
||||||
|
unsigned char buf;
|
||||||
|
|
||||||
|
for (ct = 0;;)
|
||||||
|
{
|
||||||
|
if ((ct++) == 5) return -1;
|
||||||
|
if ((fread(&buf, 1, 1, f)) < 1)
|
||||||
|
return -1;
|
||||||
|
ac = (ac << 7) | (buf & 0x7f);
|
||||||
|
if ((buf & 0x80) == 0) break;
|
||||||
|
}
|
||||||
|
*data = ac;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
evas_image_load_file_head_wbmp(Image_Entry *ie, const char *file, const char *key __UNUSED__, int *error)
|
||||||
|
{
|
||||||
|
FILE *f;
|
||||||
|
unsigned int type, w, h;
|
||||||
|
unsigned char fixed_header;
|
||||||
|
struct stat statbuf;
|
||||||
|
|
||||||
|
*error = EVAS_LOAD_ERROR_GENERIC;
|
||||||
|
f = fopen(file, "rb");
|
||||||
|
if (!f)
|
||||||
|
{
|
||||||
|
*error = EVAS_LOAD_ERROR_DOES_NOT_EXIST;
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stat(file, &statbuf) == -1) goto bail;
|
||||||
|
if (read_mb(&type, f) < 0) goto bail;
|
||||||
|
|
||||||
|
if (type != 0)
|
||||||
|
{
|
||||||
|
*error = EVAS_LOAD_ERROR_UNKNOWN_FORMAT;
|
||||||
|
goto bail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fread(&fixed_header, 1, 1, f) != 1) goto bail;
|
||||||
|
if (read_mb(&w, f) < 0) goto bail;
|
||||||
|
if (read_mb(&h, f) < 0) goto bail;
|
||||||
|
fclose(f);
|
||||||
|
ie->w = w;
|
||||||
|
ie->h = h;
|
||||||
|
|
||||||
|
*error = EVAS_LOAD_ERROR_NONE;
|
||||||
|
return EINA_TRUE;
|
||||||
|
bail:
|
||||||
|
fclose(f);
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
evas_image_load_file_data_wbmp(Image_Entry *ie, const char *file, const char *key __UNUSED__, int *error)
|
||||||
|
{
|
||||||
|
FILE *f;
|
||||||
|
unsigned int dummy, line_length;
|
||||||
|
unsigned char *line = NULL;
|
||||||
|
int cur = 0, x, y;
|
||||||
|
DATA32 *dst_data;
|
||||||
|
|
||||||
|
*error = EVAS_LOAD_ERROR_GENERIC;
|
||||||
|
f = fopen(file, "rb");
|
||||||
|
if (!f)
|
||||||
|
{
|
||||||
|
*error = EVAS_LOAD_ERROR_DOES_NOT_EXIST;
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
if (read_mb(&dummy, f) < 0) goto bail;
|
||||||
|
if (fread(&dummy, 1, 1, f) != 1) goto bail;
|
||||||
|
if (read_mb(&dummy, f) < 0) goto bail;
|
||||||
|
if (read_mb(&dummy, f) < 0) goto bail;
|
||||||
|
|
||||||
|
evas_cache_image_surface_alloc(ie, ie->w, ie->h);
|
||||||
|
dst_data = evas_cache_image_pixels(ie);
|
||||||
|
if (!dst_data)
|
||||||
|
{
|
||||||
|
*error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
|
||||||
|
goto bail;
|
||||||
|
}
|
||||||
|
|
||||||
|
line_length = (ie->w + 7) >> 3;
|
||||||
|
line = alloca(line_length);
|
||||||
|
|
||||||
|
for (y = 0; y < (int)ie->h; y++)
|
||||||
|
{
|
||||||
|
if (fread(line, 1, line_length, f) != line_length) goto bail;
|
||||||
|
for (x = 0; x < (int)ie->w; x++)
|
||||||
|
{
|
||||||
|
int idx = x >> 3;
|
||||||
|
int offset = 1 << (0x07 - (x & 0x07));
|
||||||
|
if (line[idx] & offset) dst_data[cur] = 0xffffffff;
|
||||||
|
else dst_data[cur] = 0xff000000;
|
||||||
|
cur++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
*error = EVAS_LOAD_ERROR_NONE;
|
||||||
|
return EINA_TRUE;
|
||||||
|
bail:
|
||||||
|
fclose(f);
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
module_open(Evas_Module *em)
|
||||||
|
{
|
||||||
|
if (!em) return 0;
|
||||||
|
em->functions = (void *)(&evas_image_load_wbmp_func);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
module_close(Evas_Module *em __UNUSED__)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static Evas_Module_Api evas_modapi =
|
||||||
|
{
|
||||||
|
EVAS_MODULE_API_VERSION,
|
||||||
|
"wbmp",
|
||||||
|
"none",
|
||||||
|
{
|
||||||
|
module_open,
|
||||||
|
module_close
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_IMAGE_LOADER, image_loader, wbmp);
|
||||||
|
|
||||||
|
#ifndef EVAS_STATIC_BUILD_WBMP
|
||||||
|
EVAS_EINA_MODULE_DEFINE(image_loader, wbmp);
|
||||||
|
#endif
|
Loading…
Reference in New Issue