[babl/wip/pippin/inverted-cmyk] CMYK: add back non-inverted CMYK model
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl/wip/pippin/inverted-cmyk] CMYK: add back non-inverted CMYK model
- Date: Wed, 21 Nov 2018 13:43:31 +0000 (UTC)
commit 4875717e3ae54acf1d30bd4f04ba190c35d1a909
Author: Øyvind Kolås <pippin gimp org>
Date: Tue Nov 20 18:53:53 2018 +0100
CMYK: add back non-inverted CMYK model
extensions/CMYK.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 98 insertions(+), 2 deletions(-)
---
diff --git a/extensions/CMYK.c b/extensions/CMYK.c
index 40ed246..9abec66 100644
--- a/extensions/CMYK.c
+++ b/extensions/CMYK.c
@@ -129,6 +129,104 @@ cmyka_to_cmyk (const Babl *conversion,char *src,
}
}
+/////////////////////
+static void
+cmyka_to_CMYKA (const Babl *conversion,char *src,
+ char *dst,
+ long n)
+{
+ while (n--)
+ {
+ double cyan = ((double *) src)[0];
+ double magenta = ((double *) src)[1];
+ double yellow = ((double *) src)[2];
+ double key = ((double *) src)[3];
+ double alpha = ((double *) src)[4];
+
+ ((double *) dst)[0] = (1.0-cyan) * alpha;
+ ((double *) dst)[1] = (1.0-magenta) * alpha;
+ ((double *) dst)[2] = (1.0-yellow) * alpha;
+ ((double *) dst)[3] = (1.0-key) * alpha;
+ ((double *) dst)[4] = alpha;
+
+ src += 5 * sizeof (double);
+ dst += 5 * sizeof (double);
+ }
+}
+
+static void
+CMYKA_to_cmyka (const Babl *conversion,char *src,
+ char *dst,
+ long n)
+{
+ while (n--)
+ {
+ double alpha = ((double *) src)[4];
+ double ralpha = alpha>0.000001?1.0/alpha:0.0;
+ double cyan = ((double *) src)[0] * ralpha;
+ double magenta= ((double *) src)[1] * ralpha;
+ double yellow = ((double *) src)[2] * ralpha;
+ double key = ((double *) src)[3] * ralpha;
+
+ ((double *) dst)[0] = 1.0-cyan;
+ ((double *) dst)[1] = 1.0-magenta;
+ ((double *) dst)[2] = 1.0-yellow;
+ ((double *) dst)[3] = 1.0-key;
+ ((double *) dst)[4] = alpha;
+
+ src += 5 * sizeof (double);
+ dst += 5 * sizeof (double);
+ }
+}
+
+
+
+static void
+CMYK_to_cmyka (const Babl *conversion,char *src,
+ char *dst,
+ long n)
+{
+ while (n--)
+ {
+ double cyan = ((double *) src)[0];
+ double magenta = ((double *) src)[1];
+ double yellow = ((double *) src)[2];
+ double key = ((double *) src)[3];
+
+ ((double *) dst)[0] = 1.0-cyan;
+ ((double *) dst)[1] = 1.0-magenta;
+ ((double *) dst)[2] = 1.0-yellow;
+ ((double *) dst)[3] = 1.0-key;
+ ((double *) dst)[4] = 1.0;
+
+ src += 4 * sizeof (double);
+ dst += 5 * sizeof (double);
+ }
+}
+
+static void
+cmyka_to_CMYK (const Babl *conversion,char *src,
+ char *dst,
+ long n)
+{
+ while (n--)
+ {
+ double cyan = ((double *) src)[0];
+ double magenta = ((double *) src)[1];
+ double yellow = ((double *) src)[2];
+ double key = ((double *) src)[3];
+
+ ((double *) dst)[0] = 1.0-cyan;
+ ((double *) dst)[1] = 1.0-magenta;
+ ((double *) dst)[2] = 1.0-yellow;
+ ((double *) dst)[3] = 1.0-key;
+
+ src += 5 * sizeof (double);
+ dst += 4 * sizeof (double);
+ }
+}
+
+
@@ -591,7 +689,6 @@ init (void)
NULL
);
-#if 0
babl_conversion_new (
babl_model ("cmykA"),
babl_model ("CMYK"),
@@ -616,7 +713,6 @@ init (void)
"linear", CMYKA_to_cmyka,
NULL
);
-#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]