aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/src/lib/engines/common/evas_convert_rgb_8.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-04 18:41:13 +1000
committerDavid Walter Seikel2012-01-04 18:41:13 +1000
commitdd7595a3475407a7fa96a97393bae8c5220e8762 (patch)
treee341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/evas/src/lib/engines/common/evas_convert_rgb_8.c
parentAdd the skeleton. (diff)
downloadSledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to '')
-rw-r--r--libraries/evas/src/lib/engines/common/evas_convert_rgb_8.c248
1 files changed, 248 insertions, 0 deletions
diff --git a/libraries/evas/src/lib/engines/common/evas_convert_rgb_8.c b/libraries/evas/src/lib/engines/common/evas_convert_rgb_8.c
new file mode 100644
index 0000000..f69f398
--- /dev/null
+++ b/libraries/evas/src/lib/engines/common/evas_convert_rgb_8.c
@@ -0,0 +1,248 @@
1#include "evas_common.h"
2#include "evas_convert_rgb_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_RGB_332
12void evas_common_convert_rgba_to_8bpp_rgb_332_dith (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x, int dith_y, DATA8 *pal)
13{
14 DATA32 *src_ptr;
15 DATA8 *dst_ptr;
16 int x, y;
17 DATA8 r, g, b;
18 DATA8 dith, dith2;
19
20 dst_ptr = (DATA8 *)dst;
21
22 CONVERT_LOOP_START_ROT_0();
23
24 dith = DM_SHR(DM_TABLE[(x + dith_x) & DM_MSK][(y + dith_y) & DM_MSK], 3);
25 dith2 = DM_SHR(DM_TABLE[(x + dith_x) & DM_MSK][(y + dith_y) & DM_MSK], 2);
26/* r = (R_VAL(src_ptr)) >> (8 - 3);*/
27/* g = (G_VAL(src_ptr)) >> (8 - 3);*/
28/* b = (B_VAL(src_ptr)) >> (8 - 2);*/
29/* if (((R_VAL(src_ptr) - (r << (8 - 3))) >= dith ) && (r < 0x07)) r++;*/
30/* if (((G_VAL(src_ptr) - (g << (8 - 3))) >= dith ) && (g < 0x07)) g++;*/
31/* if (((B_VAL(src_ptr) - (b << (8 - 2))) >= dith2) && (b < 0x03)) b++;*/
32 r = (R_VAL(src_ptr)) * 7 / 255;
33 if (((R_VAL(src_ptr) - (r * 255 / 7)) >= dith ) && (r < 0x07)) r++;
34 g = (G_VAL(src_ptr)) * 7 / 255;
35 if (((G_VAL(src_ptr) - (g * 255 / 7)) >= dith ) && (g < 0x07)) g++;
36 b = (B_VAL(src_ptr)) * 3 / 255;
37 if (((B_VAL(src_ptr) - (b * 255 / 3)) >= dith2) && (b < 0x03)) b++;
38
39 *dst_ptr = pal[(r << 5) | (g << 2) | (b)];
40
41 CONVERT_LOOP_END_ROT_0();
42}
43#endif
44#ifdef BUILD_CONVERT_8_RGB_666
45static DATA8 p_to_6[256];
46static DATA8 p_to_6_err[256];
47
48void evas_common_convert_rgba_to_8bpp_rgb_666_dith (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x, int dith_y, DATA8 *pal)
49{
50 DATA32 *src_ptr;
51 DATA8 *dst_ptr;
52 int x, y;
53 DATA8 r, g, b;
54 DATA8 dith;
55 static int tables_calcualted = 0;
56
57 if (!tables_calcualted)
58 {
59 int i;
60
61 tables_calcualted = 1;
62 for (i = 0; i < 256; i++)
63 p_to_6[i] = (i * 5) / 255;
64 for (i = 0; i < 256; i++)
65 p_to_6_err[i] = ((i * 5) - (p_to_6[i] * 255)) * DM_DIV / 255;
66 }
67 dst_ptr = (DATA8 *)dst;
68
69 CONVERT_LOOP_START_ROT_0();
70
71 r = p_to_6[(R_VAL(src_ptr))];
72 g = p_to_6[(G_VAL(src_ptr))];
73 b = p_to_6[(B_VAL(src_ptr))];
74 dith = DM_TABLE[(x + dith_x) & DM_MSK][(y + dith_y) & DM_MSK];
75 if ((p_to_6_err[(R_VAL(src_ptr))] >= dith ) && (r < 5)) r++;
76 if ((p_to_6_err[(G_VAL(src_ptr))] >= dith ) && (g < 5)) g++;
77 if ((p_to_6_err[(B_VAL(src_ptr))] >= dith ) && (b < 5)) b++;
78
79 *dst_ptr = pal[(r * 36) + (g * 6) + (b)];
80
81 CONVERT_LOOP_END_ROT_0();
82}
83#endif
84#ifdef BUILD_CONVERT_8_RGB_232
85void evas_common_convert_rgba_to_8bpp_rgb_232_dith (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x, int dith_y, DATA8 *pal)
86{
87 DATA32 *src_ptr;
88 DATA8 *dst_ptr;
89 int x, y;
90 DATA8 r, g, b;
91 DATA8 dith, dith2;
92
93 dst_ptr = (DATA8 *)dst;
94
95 CONVERT_LOOP_START_ROT_0();
96
97 dith = DM_SHR(DM_TABLE[(x + dith_x) & DM_MSK][(y + dith_y) & DM_MSK], 3);
98 dith2 = DM_SHR(DM_TABLE[(x + dith_x) & DM_MSK][(y + dith_y) & DM_MSK], 2);
99/* r = (R_VAL(src_ptr)) >> (8 - 2);*/
100/* g = (G_VAL(src_ptr)) >> (8 - 3);*/
101/* b = (B_VAL(src_ptr)) >> (8 - 2);*/
102/* if (((R_VAL(src_ptr) - (r << (8 - 2))) >= dith2) && (r < 0x03)) r++;*/
103/* if (((G_VAL(src_ptr) - (g << (8 - 3))) >= dith ) && (g < 0x07)) g++;*/
104/* if (((B_VAL(src_ptr) - (b << (8 - 2))) >= dith2) && (b < 0x03)) b++;*/
105 r = (R_VAL(src_ptr)) * 3 / 255;
106 if (((R_VAL(src_ptr) - (r * 255 / 3)) >= dith2) && (r < 0x03)) r++;
107 g = (G_VAL(src_ptr)) * 7 / 255;
108 if (((G_VAL(src_ptr) - (g * 255 / 7)) >= dith ) && (g < 0x07)) g++;
109 b = (B_VAL(src_ptr)) * 3 / 255;
110 if (((B_VAL(src_ptr) - (b * 255 / 3)) >= dith2) && (b < 0x03)) b++;
111
112 *dst_ptr = pal[(r << 5) | (g << 2) | (b)];
113
114 CONVERT_LOOP_END_ROT_0();
115}
116#endif
117#ifdef BUILD_CONVERT_8_RGB_222
118void evas_common_convert_rgba_to_8bpp_rgb_222_dith (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x, int dith_y, DATA8 *pal)
119{
120 DATA32 *src_ptr;
121 DATA8 *dst_ptr;
122 int x, y;
123 DATA8 r, g, b;
124 DATA8 dith;
125
126 dst_ptr = (DATA8 *)dst;
127
128 CONVERT_LOOP_START_ROT_0();
129
130 dith = DM_SHR(DM_TABLE[(x + dith_x) & DM_MSK][(y + dith_y) & DM_MSK], 2);
131/* r = (R_VAL(src_ptr)) >> (8 - 2);*/
132/* g = (G_VAL(src_ptr)) >> (8 - 2);*/
133/* b = (B_VAL(src_ptr)) >> (8 - 2);*/
134/* if (((R_VAL(src_ptr) - (r << (8 - 2))) >= dith ) && (r < 0x03)) r++;*/
135/* if (((G_VAL(src_ptr) - (g << (8 - 2))) >= dith ) && (g < 0x03)) g++;*/
136/* if (((B_VAL(src_ptr) - (b << (8 - 2))) >= dith ) && (b < 0x03)) b++;*/
137 r = (R_VAL(src_ptr)) * 3 / 255;
138 if (((R_VAL(src_ptr) - (r * 255 / 3)) >= dith ) && (r < 0x03)) r++;
139 g = (G_VAL(src_ptr)) * 3 / 255;
140 if (((G_VAL(src_ptr) - (g * 255 / 3)) >= dith ) && (g < 0x03)) g++;
141 b = (B_VAL(src_ptr)) * 3 / 255;
142 if (((B_VAL(src_ptr) - (b * 255 / 3)) >= dith ) && (b < 0x03)) b++;
143
144 *dst_ptr = pal[(r << 4) | (g << 2) | (b)];
145
146 CONVERT_LOOP_END_ROT_0();
147}
148#endif
149#ifdef BUILD_CONVERT_8_RGB_221
150void evas_common_convert_rgba_to_8bpp_rgb_221_dith (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x, int dith_y, DATA8 *pal)
151{
152 DATA32 *src_ptr;
153 DATA8 *dst_ptr;
154 int x, y;
155 DATA8 r, g, b;
156 DATA8 dith, dith2;
157
158 dst_ptr = (DATA8 *)dst;
159
160 CONVERT_LOOP_START_ROT_0();
161
162 dith = DM_SHR(DM_TABLE[(x + dith_x) & DM_MSK][(y + dith_y) & DM_MSK], 2);
163 dith2 = DM_SHR(DM_TABLE[(x + dith_x) & DM_MSK][(y + dith_y) & DM_MSK], 1);
164/* r = (R_VAL(src_ptr)) >> (8 - 2);*/
165/* g = (G_VAL(src_ptr)) >> (8 - 2);*/
166/* b = (B_VAL(src_ptr)) >> (8 - 1);*/
167/* if (((R_VAL(src_ptr) - (r << (8 - 2))) >= dith ) && (r < 0x03)) r++;*/
168/* if (((G_VAL(src_ptr) - (g << (8 - 2))) >= dith ) && (g < 0x03)) g++;*/
169/* if (((B_VAL(src_ptr) - (b << (8 - 1))) >= dith2) && (b < 0x01)) b++;*/
170 r = (R_VAL(src_ptr)) * 3 / 255;
171 if (((R_VAL(src_ptr) - (r * 255 / 3)) >= dith ) && (r < 0x03)) r++;
172 g = (G_VAL(src_ptr)) * 3 / 255;
173 if (((G_VAL(src_ptr) - (g * 255 / 3)) >= dith ) && (g < 0x03)) g++;
174 b = (B_VAL(src_ptr)) * 1 / 255;
175 if (((B_VAL(src_ptr) - (b * 255 / 1)) >= dith2) && (b < 0x01)) b++;
176
177 *dst_ptr = pal[(r << 3) | (g << 1) | (b)];
178
179 CONVERT_LOOP_END_ROT_0();
180}
181#endif
182#ifdef BUILD_CONVERT_8_RGB_121
183void evas_common_convert_rgba_to_8bpp_rgb_121_dith (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x, int dith_y, DATA8 *pal)
184{
185 DATA32 *src_ptr;
186 DATA8 *dst_ptr;
187 int x, y;
188 DATA8 r, g, b;
189 DATA8 dith, dith2;
190
191 dst_ptr = (DATA8 *)dst;
192
193 CONVERT_LOOP_START_ROT_0();
194
195 dith = DM_SHR(DM_TABLE[(x + dith_x) & DM_MSK][(y + dith_y) & DM_MSK], 2);
196 dith2 = DM_SHR(DM_TABLE[(x + dith_x) & DM_MSK][(y + dith_y) & DM_MSK], 1);
197/* r = (R_VAL(src_ptr)) >> (8 - 1);*/
198/* g = (G_VAL(src_ptr)) >> (8 - 2);*/
199/* b = (B_VAL(src_ptr)) >> (8 - 1);*/
200/* if (((R_VAL(src_ptr) - (r << (8 - 1))) >= dith2) && (r < 0x01)) r++;*/
201/* if (((G_VAL(src_ptr) - (g << (8 - 2))) >= dith ) && (g < 0x03)) g++;*/
202/* if (((B_VAL(src_ptr) - (b << (8 - 1))) >= dith2) && (b < 0x01)) b++;*/
203
204 r = (R_VAL(src_ptr)) * 1 / 255;
205 if (((R_VAL(src_ptr) - (r * 255 / 1)) >= dith2) && (r < 0x01)) r++;
206 g = (G_VAL(src_ptr)) * 3 / 255;
207 if (((G_VAL(src_ptr) - (g * 255 / 3)) >= dith ) && (g < 0x03)) g++;
208 b = (B_VAL(src_ptr)) * 1 / 255;
209 if (((B_VAL(src_ptr) - (b * 255 / 1)) >= dith2) && (b < 0x01)) b++;
210
211 *dst_ptr = pal[(r << 3) | (g << 1) | (b)];
212
213 CONVERT_LOOP_END_ROT_0();
214}
215#endif
216#ifdef BUILD_CONVERT_8_RGB_111
217void evas_common_convert_rgba_to_8bpp_rgb_111_dith (DATA32 *src, DATA8 *dst, int src_jump, int dst_jump, int w, int h, int dith_x, int dith_y, DATA8 *pal)
218{
219 DATA32 *src_ptr;
220 DATA8 *dst_ptr;
221 int x, y;
222 DATA8 r, g, b;
223 DATA8 dith;
224
225 dst_ptr = (DATA8 *)dst;
226
227 CONVERT_LOOP_START_ROT_0();
228
229 dith = DM_SHR(DM_TABLE[(x + dith_x) & DM_MSK][(y + dith_y) & DM_MSK], 1);
230/* r = (R_VAL(src_ptr)) >> (8 - 1);*/
231/* g = (G_VAL(src_ptr)) >> (8 - 1);*/
232/* b = (B_VAL(src_ptr)) >> (8 - 1);*/
233/* if (((R_VAL(src_ptr) - (r << (8 - 1))) >= dith ) && (r < 0x01)) r++;*/
234/* if (((G_VAL(src_ptr) - (g << (8 - 1))) >= dith ) && (g < 0x01)) g++;*/
235/* if (((B_VAL(src_ptr) - (b << (8 - 1))) >= dith ) && (b < 0x01)) b++;*/
236
237 r = (R_VAL(src_ptr)) * 1 / 255;
238 if (((R_VAL(src_ptr) - (r * 255 / 1)) >= dith ) && (r < 0x01)) r++;
239 g = (G_VAL(src_ptr)) * 1 / 255;
240 if (((G_VAL(src_ptr) - (g * 255 / 1)) >= dith ) && (g < 0x01)) g++;
241 b = (B_VAL(src_ptr)) * 1 / 255;
242 if (((B_VAL(src_ptr) - (b * 255 / 1)) >= dith ) && (b < 0x01)) b++;
243
244 *dst_ptr = pal[(r << 2) | (g << 1) | (b)];
245
246 CONVERT_LOOP_END_ROT_0();
247}
248#endif