summaryrefslogtreecommitdiff
path: root/src/lib/evas/common
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-12-22 19:00:41 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-12-22 19:23:01 +0900
commit2f1d666a06d374d1930cf69cf72f21c9700caf46 (patch)
tree523b35cf7e0b2b2569b7b885cfeb52f51c56b7c7 /src/lib/evas/common
parent3be0e7b63b7f9df2241e854eabd8ef924978783a (diff)
evas: PNG save of ARGY88 needs unpremul
PNG saves unpremultiplied values, so we need to do that for the newly supported ARGY88 colorspace as well. Fixes the previous commit.
Diffstat (limited to 'src/lib/evas/common')
-rw-r--r--src/lib/evas/common/evas_convert_color.c28
-rw-r--r--src/lib/evas/common/evas_convert_color.h1
2 files changed, 29 insertions, 0 deletions
diff --git a/src/lib/evas/common/evas_convert_color.c b/src/lib/evas/common/evas_convert_color.c
index 421f425221..3558b341e0 100644
--- a/src/lib/evas/common/evas_convert_color.c
+++ b/src/lib/evas/common/evas_convert_color.c
@@ -26,6 +26,34 @@ evas_common_convert_ag_premul(DATA16 *data, unsigned int len)
26 return nas; 26 return nas;
27} 27}
28 28
29EAPI void
30evas_common_convert_ag_unpremul(DATA16 *data, unsigned int len)
31{
32 DATA16 *de = data + len;
33 DATA16 p_val = 0x0000, p_res = 0x0000;
34
35 while (data < de)
36 {
37 if (p_val == *data) *data = p_res;
38 else
39 {
40 DATA16 a = (*data >> 8);
41
42 p_val = *data;
43 if ((a > 0) && (a < 255))
44 {
45 *data = ((a << 8) | (((*data & 0xff) * 0xff) / a));
46 }
47 else if (a == 0)
48 {
49 *data = 0x0000;
50 }
51 p_res = *data;
52 }
53 data++;
54 }
55}
56
29EAPI DATA32 57EAPI DATA32
30evas_common_convert_argb_premul(DATA32 *data, unsigned int len) 58evas_common_convert_argb_premul(DATA32 *data, unsigned int len)
31{ 59{
diff --git a/src/lib/evas/common/evas_convert_color.h b/src/lib/evas/common/evas_convert_color.h
index c3c07a3ca9..54bd59e138 100644
--- a/src/lib/evas/common/evas_convert_color.h
+++ b/src/lib/evas/common/evas_convert_color.h
@@ -3,6 +3,7 @@
3 3
4 4
5EAPI DATA32 evas_common_convert_ag_premul (DATA16 *data, unsigned int len); 5EAPI DATA32 evas_common_convert_ag_premul (DATA16 *data, unsigned int len);
6EAPI void evas_common_convert_ag_unpremul (DATA16 *data, unsigned int len);
6EAPI DATA32 evas_common_convert_argb_premul (DATA32 *src, unsigned int len); 7EAPI DATA32 evas_common_convert_argb_premul (DATA32 *src, unsigned int len);
7EAPI void evas_common_convert_argb_unpremul (DATA32 *src, unsigned int len); 8EAPI void evas_common_convert_argb_unpremul (DATA32 *src, unsigned int len);
8EAPI void evas_common_convert_color_argb_premul (int a, int *r, int *g, int *b); 9EAPI void evas_common_convert_color_argb_premul (int a, int *r, int *g, int *b);