[babl/wip/pippin/inverted-cmyk] CMYK: drop rgb related conversions - through the new reference system, we aim to have cmyk be a sepa
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl/wip/pippin/inverted-cmyk] CMYK: drop rgb related conversions - through the new reference system, we aim to have cmyk be a sepa
- Date: Wed, 21 Nov 2018 13:43:26 +0000 (UTC)
commit 49e5c2376b0f473bce8def7dc7855abee64c24fa
Author: Øyvind Kolås <pippin gimp org>
Date: Tue Nov 20 17:56:10 2018 +0100
CMYK: drop rgb related conversions - through the new reference system, we aim to have cmyk be a separate
internally consistent universe to RGB
extensions/CMYK.c | 387 +++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 283 insertions(+), 104 deletions(-)
---
diff --git a/extensions/CMYK.c b/extensions/CMYK.c
index 711284b..40ed246 100644
--- a/extensions/CMYK.c
+++ b/extensions/CMYK.c
@@ -32,6 +32,108 @@
#include "babl.h"
#include "base/util.h"
+
+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] = (cyan) * alpha;
+ ((double *) dst)[1] = (magenta) * alpha;
+ ((double *) dst)[2] = (yellow) * alpha;
+ ((double *) dst)[3] = (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] = cyan;
+ ((double *) dst)[1] = magenta;
+ ((double *) dst)[2] = yellow;
+ ((double *) dst)[3] = 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] = cyan;
+ ((double *) dst)[1] = magenta;
+ ((double *) dst)[2] = yellow;
+ ((double *) dst)[3] = 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] = cyan;
+ ((double *) dst)[1] = magenta;
+ ((double *) dst)[2] = yellow;
+ ((double *) dst)[3] = key;
+
+ src += 5 * sizeof (double);
+ dst += 4 * sizeof (double);
+ }
+}
+
+
+
+
+
+#if 0
static void
rgba_to_cmykA (const Babl *conversion,char *src,
char *dst,
@@ -83,30 +185,6 @@ rgba_to_cmykA (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] = (cyan) * alpha;
- ((double *) dst)[1] = (magenta) * alpha;
- ((double *) dst)[2] = (yellow) * alpha;
- ((double *) dst)[3] = (key) * alpha;
- ((double *) dst)[4] = alpha;
-
- src += 5 * sizeof (double);
- dst += 5 * sizeof (double);
- }
-}
-
static void
cmykA_to_rgba (const Babl *conversion,char *src,
char *dst,
@@ -153,32 +231,6 @@ cmykA_to_rgba (const Babl *conversion,char *src,
}
}
-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] = cyan;
- ((double *) dst)[1] = magenta;
- ((double *) dst)[2] = yellow;
- ((double *) dst)[3] = key;
- ((double *) dst)[4] = alpha;
-
- src += 5 * sizeof (double);
- dst += 5 * sizeof (double);
- }
-}
-
-
static void
rgba_to_cmyka (const Babl *conversion,char *src,
char *dst,
@@ -359,31 +411,6 @@ cmyk_to_rgba (const Babl *conversion,char *src,
}
}
-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] = cyan;
- ((double *) dst)[1] = magenta;
- ((double *) dst)[2] = yellow;
- ((double *) dst)[3] = key;
- ((double *) dst)[4] = 1.0;
-
- src += 4 * sizeof (double);
- dst += 5 * sizeof (double);
- }
-}
-
-
-
static void
rgba_to_cmy (const Babl *conversion,char *src,
char *dst,
@@ -437,29 +464,7 @@ cmy_to_rgba (const Babl *conversion,char *src,
dst += 4 * 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] = cyan;
- ((double *) dst)[1] = magenta;
- ((double *) dst)[2] = yellow;
- ((double *) dst)[3] = key;
-
- src += 5 * sizeof (double);
- dst += 4 * sizeof (double);
- }
-}
+#endif
int init (void);
@@ -586,9 +591,36 @@ init (void)
NULL
);
+#if 0
+ babl_conversion_new (
+ babl_model ("cmykA"),
+ babl_model ("CMYK"),
+ "linear", cmyka_to_CMYK,
+ NULL
+ );
+ babl_conversion_new (
+ babl_model ("CMYK"),
+ babl_model ("cmykA"),
+ "linear", CMYK_to_cmyka,
+ NULL
+ );
+ babl_conversion_new (
+ babl_model ("cmykA"),
+ babl_model ("CaMaYaKaA"),
+ "linear", cmyka_to_CMYKA,
+ NULL
+ );
+ babl_conversion_new (
+ babl_model ("CaMaYaKaA"),
+ babl_model ("cmykA"),
+ "linear", CMYKA_to_cmyka,
+ NULL
+ );
+#endif
+#if 0
babl_conversion_new (
babl_model ("RGBA"),
@@ -627,12 +659,6 @@ init (void)
"linear", cmyk_to_rgba,
NULL
);
- babl_conversion_new (
- babl_model ("cmyk"),
- babl_model ("cmykA"),
- "linear", cmyk_to_cmyka,
- NULL
- );
babl_conversion_new (
babl_model ("RGBA"),
babl_model ("cmy"),
@@ -645,6 +671,7 @@ init (void)
"linear", cmy_to_rgba,
NULL
);
+#endif
babl_format_new (
"name", "camayakaA float",
@@ -797,6 +824,158 @@ init (void)
NULL
);
+ /********************************/
+ babl_format_new (
+ "name", "CaMaYaKaA float",
+ babl_model ("CaMaYaKaA"),
+ babl_type ("float"),
+ babl_component ("Ca"),
+ babl_component ("Ma"),
+ babl_component ("Ya"),
+ babl_component ("Ka"),
+ babl_component ("A"),
+ NULL
+ );
+ babl_format_new (
+ "name", "CMYKA float",
+ babl_model ("CMYKA"),
+ babl_type ("float"),
+ babl_component ("Cyan"),
+ babl_component ("Magenta"),
+ babl_component ("Yellow"),
+ babl_component ("Key"),
+ babl_component ("A"),
+ NULL
+ );
+ babl_format_new (
+ "name", "CMYK float",
+ babl_model ("CMYK"),
+ babl_type ("float"),
+ babl_component ("Cyan"),
+ babl_component ("Magenta"),
+ babl_component ("Yellow"),
+ babl_component ("Key"),
+ NULL
+ );
+ babl_format_new (
+ "name", "CMY float",
+ babl_model ("CMY"),
+ babl_type ("float"),
+ babl_component ("Cyan"),
+ babl_component ("Magenta"),
+ babl_component ("Yellow"),
+ NULL
+ );
+
+ babl_format_new (
+ "name", "CMYK u8",
+ babl_model ("CMYK"),
+ babl_type ("u8"),
+ babl_component ("Cyan"),
+ babl_component ("Magenta"),
+ babl_component ("Yellow"),
+ babl_component ("Key"),
+ NULL
+ );
+ babl_format_new (
+ "name", "CMYKA u8",
+ babl_model ("CMYKA"),
+ babl_type ("u8"),
+ babl_component ("Cyan"),
+ babl_component ("Magenta"),
+ babl_component ("Yellow"),
+ babl_component ("Key"),
+ babl_component ("A"),
+ NULL
+ );
+
+ babl_format_new (
+ "name", "CMYK u16",
+ babl_model ("CMYK"),
+ babl_type ("u16"),
+ babl_component ("Cyan"),
+ babl_component ("Magenta"),
+ babl_component ("Yellow"),
+ babl_component ("Key"),
+ NULL
+ );
+ babl_format_new (
+ "name", "CMYKA u16",
+ babl_model ("CMYKA"),
+ babl_type ("u16"),
+ babl_component ("Cyan"),
+ babl_component ("Magenta"),
+ babl_component ("Yellow"),
+ babl_component ("Key"),
+ babl_component ("A"),
+ NULL
+ );
+ babl_format_new (
+ "name", "CMYK u32",
+ babl_model ("CMYK"),
+ babl_type ("u32"),
+ babl_component ("Cyan"),
+ babl_component ("Magenta"),
+ babl_component ("Yellow"),
+ babl_component ("Key"),
+ NULL
+ );
+ babl_format_new (
+ "name", "CMYKA u32",
+ babl_model ("CMYKA"),
+ babl_type ("u32"),
+ babl_component ("Cyan"),
+ babl_component ("Magenta"),
+ babl_component ("Yellow"),
+ babl_component ("Key"),
+ babl_component ("A"),
+ NULL
+ );
+
+ babl_format_new (
+ "name", "CMYK float",
+ babl_model ("CMYK"),
+ babl_type ("float"),
+ babl_component ("Cyan"),
+ babl_component ("Magenta"),
+ babl_component ("Yellow"),
+ babl_component ("Key"),
+ NULL
+ );
+ babl_format_new (
+ "name", "CMYKA float",
+ babl_model ("CMYKA"),
+ babl_type ("float"),
+ babl_component ("Cyan"),
+ babl_component ("Magenta"),
+ babl_component ("Yellow"),
+ babl_component ("Key"),
+ babl_component ("A"),
+ NULL
+ );
+ babl_format_new (
+ "name", "CaMaYaKaA u16",
+ babl_model ("CaMaYaKaA"),
+ babl_type ("u16"),
+ babl_component ("Ca"),
+ babl_component ("Ma"),
+ babl_component ("Yea"),
+ babl_component ("Ka"),
+ babl_component ("A"),
+ NULL
+ );
+ babl_format_new (
+ "name", "CaMaYaKaA half",
+ babl_model ("CaMaYaKaA"),
+ babl_type ("half"),
+ babl_component ("Ca"),
+ babl_component ("Ma"),
+ babl_component ("Yea"),
+ babl_component ("Ka"),
+ babl_component ("A"),
+ NULL
+ );
+
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]