* evas: Add convertion function for 8bpp grayscale no pal (256 and 16 values).
authorcedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 6 Nov 2009 15:15:37 +0000 (15:15 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 6 Nov 2009 15:15:37 +0000 (15:15 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@43491 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

configure.ac
src/lib/engines/common/evas_convert_gry_8.c
src/lib/engines/common/evas_convert_main.c

index 7fe7447..bcde7f2 100644 (file)
@@ -1147,6 +1147,12 @@ EVAS_CONVERT_ROT(32, RGB, 270)
 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"
 AC_MSG_CHECKING(whether to build 8bpp grayscale 64-palette converter code)
@@ -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"
index a547114..7754c86 100644 (file)
@@ -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
index 18727ae..73790fd 100644 (file)
@@ -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;