From 992a1b4f139c46ff6accb3c59582ec578d0516fe Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 6 Nov 2009 15:15:37 +0000 Subject: [PATCH] * evas: Add convertion function for 8bpp grayscale no pal (256 and 16 values). SVN revision: 43491 --- legacy/evas/configure.ac | 8 +++ .../lib/engines/common/evas_convert_gry_8.c | 60 ++++++++++++++++++- .../lib/engines/common/evas_convert_main.c | 9 +++ 3 files changed, 75 insertions(+), 2 deletions(-) diff --git a/legacy/evas/configure.ac b/legacy/evas/configure.ac index 7fe7447e43..bcde7f22c7 100644 --- a/legacy/evas/configure.ac +++ b/legacy/evas/configure.ac @@ -1146,6 +1146,12 @@ EVAS_CONVERT_ROT(32, RGB, 270) ## Convert to 32bpp RGB with rotation of 90 EVAS_CONVERT_ROT(32, RGB, 90) +####################################### +## Convert to 8bpp grayscale with 256 value, no palette +EVAS_CONVERT_COLOR(8, GRY, 1) +## Convert to 8bpp grayscale with 16 value, no palette +EVAS_CONVERT_COLOR(8, GRY, 16) + ####################################### ## Convert to 8bpp grayscale, 64-palette conv_8_grayscale_64="yes" @@ -1383,6 +1389,8 @@ 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 (256)....: $conv_8_gry_1" +echo " 8bpp Grayscale (16).....: $conv_8_gry_16" echo " 8bpp Grayscale 64-pal...: $conv_8_grayscale_64" # FIXME: add grayscale and B&W support echo " 16bpp RGB 565...........: $conv_16_rgb_565" diff --git a/legacy/evas/src/lib/engines/common/evas_convert_gry_8.c b/legacy/evas/src/lib/engines/common/evas_convert_gry_8.c index a547114052..7754c861da 100644 --- a/legacy/evas/src/lib/engines/common/evas_convert_gry_8.c +++ b/legacy/evas/src/lib/engines/common/evas_convert_gry_8.c @@ -5,8 +5,37 @@ #include "evas_common.h" #include "evas_convert_gry_8.h" +#ifdef USE_DITHER_44 +extern const DATA8 _evas_dither_44[4][4]; +#endif +#ifdef USE_DITHER_128128 +extern const DATA8 _evas_dither_128128[128][128]; +#endif + #ifdef BUILD_CONVERT_8_GRY_1 -void evas_common_convert_rgba_to_8bpp_gry_256_dith (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x, int dith_y, DATA8 *pal){} +void evas_common_convert_rgba_to_8bpp_gry_256_dith (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 r, g, b; + DATA32 gry8; + + dst_ptr = (DATA8 *)dst; + + CONVERT_LOOP_START_ROT_0(); + + r = (R_VAL(src_ptr)); + g = (G_VAL(src_ptr)); + b = (B_VAL(src_ptr)); + + // Y = 0.299 * R + 0.587 * G + 0.114 * B; + gry8 = ((r * 19595) + (g * 38469) + (b * 7471)) >> 16; + + *dst_ptr = gry8; + + CONVERT_LOOP_END_ROT_0(); +} #endif #ifdef BUILD_CONVERT_8_GRY_4 @@ -14,7 +43,34 @@ void evas_common_convert_rgba_to_8bpp_gry_64_dith (DATA32 *src, DATA8 *dst, #endif #ifdef BUILD_CONVERT_8_GRY_16 -void evas_common_convert_rgba_to_8bpp_gry_16_dith (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x, int dith_y, DATA8 *pal){} +void evas_common_convert_rgba_to_8bpp_gry_16_dith (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 r, g, b; + DATA32 gry8; + DATA8 dith, dith2; + + dst_ptr = (DATA8 *)dst; + + CONVERT_LOOP_START_ROT_0(); + + dith = DM_TABLE[(x + dith_x) & DM_MSK][(y + dith_y) & DM_MSK] >> DM_SHF(4); + + r = (R_VAL(src_ptr)); + g = (G_VAL(src_ptr)); + b = (B_VAL(src_ptr)); + + // Y = 0.299 * R + 0.587 * G + 0.114 * B; + gry8 = ((r * 19595) + (g * 38469) + (b * 7471)) >> 16; + + if (((gry8 - gry8 * 255 / 4) >= dith) && (gry8 < 0x07)) gry8++; + + *dst_ptr = gry8; + + CONVERT_LOOP_END_ROT_0(); +} #endif #ifdef BUILD_CONVERT_8_GRY_64 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 18727ae4b0..73790fdd4e 100644 --- a/legacy/evas/src/lib/engines/common/evas_convert_main.c +++ b/legacy/evas/src/lib/engines/common/evas_convert_main.c @@ -8,6 +8,7 @@ #include "evas_convert_rgb_24.h" #include "evas_convert_rgb_32.h" #include "evas_convert_grypal_6.h" +#include "evas_convert_gry_8.h" #include "evas_convert_yuv.h" const DATA8 _evas_dither_44[4][4] = @@ -162,6 +163,14 @@ evas_common_convert_func_get(DATA8 *dest, int w, int h, int depth, DATA32 rmask, { if (depth == 8) { +#ifdef BUILD_CONVERT_8_GRY_1 + if (pal_mode == PAL_MODE_NONE) + return evas_common_convert_rgba_to_8bpp_gry_256_dith; +#endif +#ifdef BUILD_CONVERT_8_GRY_16 + if (pal_mode == PAL_MODE_NONE) + return evas_common_convert_rgba_to_8bpp_gry_16_dith; +#endif #ifdef BUILD_CONVERT_8_RGB_332 if (pal_mode == PAL_MODE_RGB332) return evas_common_convert_rgba_to_8bpp_rgb_332_dith;