aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/src/lib/engines/common/evas_convert_colorspace.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_colorspace.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 'libraries/evas/src/lib/engines/common/evas_convert_colorspace.c')
-rw-r--r--libraries/evas/src/lib/engines/common/evas_convert_colorspace.c186
1 files changed, 186 insertions, 0 deletions
diff --git a/libraries/evas/src/lib/engines/common/evas_convert_colorspace.c b/libraries/evas/src/lib/engines/common/evas_convert_colorspace.c
new file mode 100644
index 0000000..013c2e7
--- /dev/null
+++ b/libraries/evas/src/lib/engines/common/evas_convert_colorspace.c
@@ -0,0 +1,186 @@
1#include "evas_common.h"
2#include "evas_convert_colorspace.h"
3
4#define CONVERT_RGB_565_TO_RGB_888(s) \
5 (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \
6 ((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) | \
7 ((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000)))
8
9#define CONVERT_A5P_TO_A8(s) \
10 ((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7))
11
12#define CONVERT_ARGB_8888_TO_A_8(s) ((s) >> 24)
13
14
15static inline void *
16evas_common_convert_argb8888_to_rgb565_a5p(void *data __UNUSED__, int w __UNUSED__, int h __UNUSED__, int stride __UNUSED__, Eina_Bool has_alpha __UNUSED__)
17{
18 return NULL;
19}
20
21static inline void *
22evas_common_convert_rgb565_a5p_to_argb8888(void *data, int w, int h, int stride, Eina_Bool has_alpha)
23{
24 DATA16 *src, *end;
25 DATA32 *ret, *dst;
26
27 src = data;
28 end = src + (stride * h);
29 ret = malloc(w * h * sizeof(DATA32));
30
31 dst = ret;
32 if (has_alpha)
33 {
34 DATA8 *alpha;
35
36 alpha = (DATA8 *)end;
37 for (; src < end; src++, alpha++, dst++)
38 *dst = (CONVERT_A5P_TO_A8(*alpha) << 24) |
39 CONVERT_RGB_565_TO_RGB_888(*src);
40 }
41 else
42 {
43 for (; src < end; src++, dst++)
44 *dst = CONVERT_RGB_565_TO_RGB_888(*src);
45 }
46 return ret;
47}
48
49static inline void *
50evas_common_convert_argb8888_to_a8(void *data, int w, int h, int stride, Eina_Bool has_alpha)
51{
52 uint32_t *src, *end;
53 uint8_t *ret, *dst;
54
55 src = data;
56 end = src + (stride * h);
57 ret = malloc(w * h);
58 if (!ret) return NULL;
59
60 if (!has_alpha)
61 {
62 return memset(ret, 0xff, w * h);
63 }
64
65 dst = ret;
66 for ( ; src < end ; src++, dst++)
67 *dst = CONVERT_ARGB_8888_TO_A_8(*src);
68 return ret;
69}
70
71
72
73EAPI void *
74evas_common_convert_argb8888_to(void *data, int w, int h, int stride, Eina_Bool has_alpha, Evas_Colorspace cspace)
75{
76 switch (cspace)
77 {
78 case EVAS_COLORSPACE_RGB565_A5P:
79 return evas_common_convert_argb8888_to_rgb565_a5p(data, w, h, stride, has_alpha);
80 default:
81 break;
82 }
83 return NULL;
84}
85
86EAPI void *
87evas_common_convert_rgb565_a5p_to(void *data, int w, int h, int stride, Eina_Bool has_alpha, Evas_Colorspace cspace)
88{
89 switch (cspace)
90 {
91 case EVAS_COLORSPACE_ARGB8888:
92 return evas_common_convert_rgb565_a5p_to_argb8888(data, w, h, stride, has_alpha);
93 default:
94 break;
95 }
96 return NULL;
97}
98
99EAPI void *
100evas_common_convert_yuv_422_601_to(void *data, int w, int h, Evas_Colorspace cspace)
101{
102 switch (cspace)
103 {
104 case EVAS_COLORSPACE_ARGB8888:
105 {
106 void *dst;
107
108 fprintf(stderr, "to argb888\n");
109
110 dst = malloc(sizeof (unsigned int) * w * h);
111 if (!dst) return NULL;
112
113 evas_common_convert_yuv_422_601_rgba(data, dst, w, h);
114 return dst;
115 }
116 default:
117 break;
118 }
119 return NULL;
120}
121
122EAPI void *
123evas_common_convert_yuv_422P_601_to(void *data, int w, int h, Evas_Colorspace cspace)
124{
125 switch (cspace)
126 {
127 case EVAS_COLORSPACE_ARGB8888:
128 {
129 void *dst;
130
131 dst = malloc(sizeof (unsigned int) * w * h);
132 if (!dst) return NULL;
133
134 evas_common_convert_yuv_420p_601_rgba(data, dst, w, h);
135 break;
136 }
137 default:
138 break;
139 }
140 return NULL;
141}
142
143EAPI void *
144evas_common_convert_yuv_420_601_to(void *data, int w, int h, Evas_Colorspace cspace)
145{
146 switch (cspace)
147 {
148 case EVAS_COLORSPACE_ARGB8888:
149 {
150 void *dst;
151
152 dst = malloc(sizeof (unsigned int) * w * h);
153 if (!dst) return NULL;
154
155 evas_common_convert_yuv_420_601_rgba(data, dst, w, h);
156 break;
157 }
158 default:
159 break;
160 }
161 return NULL;
162}
163
164EAPI void *
165evas_common_convert_yuv_420T_601_to(void *data, int w, int h, Evas_Colorspace cspace)
166{
167 switch (cspace)
168 {
169 case EVAS_COLORSPACE_ARGB8888:
170 {
171 void *dst;
172
173 dst = malloc(sizeof (unsigned int) * w * h);
174 if (!dst) return NULL;
175
176 evas_common_convert_yuv_420_601_rgba(data, dst, w, h);
177 break;
178 }
179 default:
180 break;
181 }
182 return NULL;
183}
184
185
186/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/