From 226e4e5e16a9c68c0c7d25bf93910291178eb1fd Mon Sep 17 00:00:00 2001 From: Mikhail Gusarov Date: Mon, 17 Aug 2009 01:41:07 +0000 Subject: [PATCH] From: Mikhail Gusarov Subject: [E-devel] [evas] Add RGBA -> grayscale 64 entries palette conversion This is needed for E-Ink devices outta there. Names of new files, configure.ac variables and macros are awful, suggestions are welcome. SVN revision: 41825 --- legacy/evas/configure.ac | 22 +++++++++++++++ .../evas/src/lib/engines/common/Makefile.am | 2 ++ .../engines/common/evas_convert_grypal_6.c | 27 +++++++++++++++++++ .../engines/common/evas_convert_grypal_6.h | 10 +++++++ .../lib/engines/common/evas_convert_main.c | 5 ++++ 5 files changed, 66 insertions(+) create mode 100644 legacy/evas/src/lib/engines/common/evas_convert_grypal_6.c create mode 100644 legacy/evas/src/lib/engines/common/evas_convert_grypal_6.h diff --git a/legacy/evas/configure.ac b/legacy/evas/configure.ac index 4389b498c2..c130d6b0cc 100644 --- a/legacy/evas/configure.ac +++ b/legacy/evas/configure.ac @@ -1072,6 +1072,27 @@ EVAS_CONVERT_ROT(32, RGB, 270) ## Convert to 32bpp RGB with rotation of 90 EVAS_CONVERT_ROT(32, RGB, 90) +####################################### +## Convert to 8bpp grayscale, 64-palette +conv_8_grayscale_64="yes" +AC_MSG_CHECKING(whether to build 8bpp grayscale 64-palette converter code) +AC_ARG_ENABLE(convert-8-grayscale-64, + AC_HELP_STRING([--disable-convert-8-grayscale-64], [disable 8bpp grayscale 64-palette converter code]), + [ + if test "$enableval" = "xyes"; then + AC_DEFINE(BUILD_CONVERT_8_GRAYSCALE_64, 1, [8bpp Grayscale 64-palette Converter Support]) + conv_8_grayscale_64="yes" + else + conv_8_grayscale_64="no" + fi + ], [ + if test "x$conv_8_grayscale_64" = "xyes"; then + AC_DEFINE(BUILD_CONVERT_8_GRAYSCALE_64, 1, [32bpp Grayscale 64-palette Converter Support]) + fi + ] +) +AC_MSG_RESULT($conv_8_grayscale_64) + ## valgrind want_valgrind="no" have_valgrind="no" @@ -1286,6 +1307,7 @@ echo " 8bpp RGB 222............: $conv_8_rgb_222" echo " 8bpp RGB 221............: $conv_8_rgb_221" echo " 8bpp RGB 121............: $conv_8_rgb_121" echo " 8bpp RGB 111............: $conv_8_rgb_111" +echo " 8bpp Grayscale 64-pal...: $conv_8_grayscale_64" # FIXME: add grayscale and B&W support echo " 16bpp RGB 565...........: $conv_16_rgb_565" echo " 16bpp BGR 565...........: $conv_16_bgr_565" diff --git a/legacy/evas/src/lib/engines/common/Makefile.am b/legacy/evas/src/lib/engines/common/Makefile.am index 4b998bc15e..75a358c13f 100644 --- a/legacy/evas/src/lib/engines/common/Makefile.am +++ b/legacy/evas/src/lib/engines/common/Makefile.am @@ -35,6 +35,7 @@ evas_convert_rgb_16.c \ evas_convert_rgb_24.c \ evas_convert_rgb_32.c \ evas_convert_rgb_8.c \ +evas_convert_grypal_6.c \ evas_convert_yuv.c \ evas_cpu.c \ evas_draw_main.c \ @@ -78,6 +79,7 @@ evas_convert_colorspace.h \ evas_convert_gry_1.h \ evas_convert_gry_4.h \ evas_convert_gry_8.h \ +evas_convert_grypal_6.h \ evas_convert_main.h \ evas_convert_rgb_16.h \ evas_convert_rgb_24.h \ diff --git a/legacy/evas/src/lib/engines/common/evas_convert_grypal_6.c b/legacy/evas/src/lib/engines/common/evas_convert_grypal_6.c new file mode 100644 index 0000000000..64d375615b --- /dev/null +++ b/legacy/evas/src/lib/engines/common/evas_convert_grypal_6.c @@ -0,0 +1,27 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ + +#include "evas_common.h" +#include "evas_convert_grypal_6.h" + +#ifdef BUILD_CONVERT_8_GRAYSCALE_64 +void evas_common_convert_rgba_to_8bpp_pal_gray64 (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x, int dith_y, DATA8 *pal) +{ + DATA32 *src_ptr; + DATA8 *dst_ptr; + int x, y; + DATA8 Y; + + dst_ptr = dst; + CONVERT_LOOP_START_ROT_0(); + + /* RGB -> YUV conversion */ + Y = ((R_VAL(src_ptr) * 76) + + (G_VAL(src_ptr) * 151) + + (B_VAL(src_ptr) * 29)) >> 10; + *dst_ptr = pal[Y]; + + CONVERT_LOOP_END_ROT_0(); +} +#endif diff --git a/legacy/evas/src/lib/engines/common/evas_convert_grypal_6.h b/legacy/evas/src/lib/engines/common/evas_convert_grypal_6.h new file mode 100644 index 0000000000..38ccda8290 --- /dev/null +++ b/legacy/evas/src/lib/engines/common/evas_convert_grypal_6.h @@ -0,0 +1,10 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ + +#ifndef _EVAS_CONVERT_GRY_4_H +#define _EVAS_CONVERT_GRY_4_H + +void evas_common_convert_rgba_to_8bpp_pal_gray64 (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x, int dith_y, DATA8 *pal); + +#endif /* _EVAS_CONVERT_GRY_4_H */ diff --git a/legacy/evas/src/lib/engines/common/evas_convert_main.c b/legacy/evas/src/lib/engines/common/evas_convert_main.c index 627146420b..6182667d0a 100644 --- a/legacy/evas/src/lib/engines/common/evas_convert_main.c +++ b/legacy/evas/src/lib/engines/common/evas_convert_main.c @@ -7,6 +7,7 @@ #include "evas_convert_rgb_16.h" #include "evas_convert_rgb_24.h" #include "evas_convert_rgb_32.h" +#include "evas_convert_grypal_6.h" #include "evas_convert_yuv.h" #ifdef USE_DITHER_44 @@ -192,6 +193,10 @@ evas_common_convert_func_get(DATA8 *dest, int w, int h, int depth, DATA32 rmask, #ifdef BUILD_CONVERT_8_RGB_111 if (pal_mode == PAL_MODE_RGB111) return evas_common_convert_rgba_to_8bpp_rgb_111_dith; +#endif +#ifdef BUILD_CONVERT_8_GRAYSCALE_64 + if (pal_mode == PAL_MODE_GRAY64) + return evas_common_convert_rgba_to_8bpp_pal_gray64; #endif } if (depth == 1)