aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/src/lib/engines/common/evas_convert_gry_8.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/evas/src/lib/engines/common/evas_convert_gry_8.c')
-rw-r--r--libraries/evas/src/lib/engines/common/evas_convert_gry_8.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/libraries/evas/src/lib/engines/common/evas_convert_gry_8.c b/libraries/evas/src/lib/engines/common/evas_convert_gry_8.c
new file mode 100644
index 0000000..9bc5ca7
--- /dev/null
+++ b/libraries/evas/src/lib/engines/common/evas_convert_gry_8.c
@@ -0,0 +1,78 @@
1#include "evas_common.h"
2#include "evas_convert_gry_8.h"
3
4#ifdef USE_DITHER_44
5extern const DATA8 _evas_dither_44[4][4];
6#endif
7#ifdef USE_DITHER_128128
8extern const DATA8 _evas_dither_128128[128][128];
9#endif
10
11#ifdef BUILD_CONVERT_8_GRY_1
12void 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 __UNUSED__, int dith_y __UNUSED__, DATA8 *pal __UNUSED__)
13{
14 DATA32 *src_ptr;
15 DATA8 *dst_ptr;
16 int x, y;
17 DATA8 r, g, b;
18 DATA32 gry8;
19
20 dst_ptr = (DATA8 *)dst;
21
22 CONVERT_LOOP_START_ROT_0();
23
24 r = (R_VAL(src_ptr));
25 g = (G_VAL(src_ptr));
26 b = (B_VAL(src_ptr));
27
28 // Y = 0.299 * R + 0.587 * G + 0.114 * B;
29 gry8 = ((r * 19595) + (g * 38469) + (b * 7471)) >> 16;
30
31 *dst_ptr = gry8;
32
33 CONVERT_LOOP_END_ROT_0();
34}
35#endif
36
37#ifdef BUILD_CONVERT_8_GRY_4
38void evas_common_convert_rgba_to_8bpp_gry_64_dith (DATA32 *src __UNUSED__, DATA8 *dst __UNUSED__, int src_jump __UNUSED__, int dst_jump __UNUSED__, int w __UNUSED__, int h __UNUSED__, int dith_x __UNUSED__, int dith_y __UNUSED__, DATA8 *pal __UNUSED__){}
39#endif
40
41#ifdef BUILD_CONVERT_8_GRY_16
42void 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 __UNUSED__)
43{
44 DATA32 *src_ptr;
45 DATA8 *dst_ptr;
46 int x, y;
47 DATA8 r, g, b;
48 DATA32 gry8;
49 DATA8 dith;
50
51 dst_ptr = (DATA8 *)dst;
52
53 CONVERT_LOOP_START_ROT_0();
54
55 dith = DM_TABLE[(x + dith_x) & DM_MSK][(y + dith_y) & DM_MSK] >> DM_SHF(4);
56
57 r = (R_VAL(src_ptr));
58 g = (G_VAL(src_ptr));
59 b = (B_VAL(src_ptr));
60
61 // Y = 0.299 * R + 0.587 * G + 0.114 * B;
62 gry8 = ((r * 19595) + (g * 38469) + (b * 7471)) >> 16;
63
64 if (((gry8 - gry8 * 255 / 4) >= dith) && (gry8 < 0x07)) gry8++;
65
66 *dst_ptr = gry8;
67
68 CONVERT_LOOP_END_ROT_0();
69}
70#endif
71
72#ifdef BUILD_CONVERT_8_GRY_64
73void evas_common_convert_rgba_to_8bpp_gry_4_dith (DATA32 *src __UNUSED__, DATA8 *dst __UNUSED__, int src_jump __UNUSED__, int dst_jump __UNUSED__, int w __UNUSED__, int h __UNUSED__, int dith_x __UNUSED__, int dith_y __UNUSED__, DATA8 *pal __UNUSED__){}
74#endif
75
76#ifdef BUILD_CONVERT_8_GRY_256
77void evas_common_convert_rgba_to_8bpp_gry_1_dith (DATA32 *src __UNUSED__, DATA8 *dst __UNUSED__, int src_jump __UNUSED__, int dst_jump __UNUSED__, int w __UNUSED__, int h __UNUSED__, int dith_x __UNUSED__, int dith_y __UNUSED__, DATA8 *pal __UNUSED__){}
78#endif