[babl/wip/pippin/inverted-cmyk: 9/9] reference: some cmyk based to rgb based formats go through pipeline, but cmyk to rgb is missing



commit 9620f6a4c539d53cf8ceae878520c3ba393934ca
Author: Øyvind Kolås <pippin gimp org>
Date:   Tue Nov 6 14:20:44 2018 +0100

    reference: some cmyk based to rgb based formats go through pipeline, but cmyk to rgb is missing

 babl/babl-fish-reference.c | 83 ++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 80 insertions(+), 3 deletions(-)
---
diff --git a/babl/babl-fish-reference.c b/babl/babl-fish-reference.c
index 8b7adc1..c6eb43c 100644
--- a/babl/babl-fish-reference.c
+++ b/babl/babl-fish-reference.c
@@ -29,6 +29,7 @@ assert_conversion_find (const void *source,
   if (!ret)
     babl_fatal ("failed finding conversion between %s and %s aborting",
                 babl_get_name (source), babl_get_name (destination));
+
   return ret;
 }
 
@@ -252,7 +253,6 @@ convert_from_double (BablFormat *destination_fmt,
   src_img->stride[0] = 0;
 
   dst_img->data[0]  = destination_buf;
-  dst_img->type[0]  = (BablType *) babl_type_from_id (BABL_DOUBLE);
   dst_img->pitch[0] = destination_fmt->bytes_per_pixel;
   dst_img->stride[0] = 0;
 
@@ -812,10 +812,87 @@ babl_fish_reference_process_double (const Babl *babl,
 
       /* we now have right data in cmyk_double_buf  */
 
-      /* */
 
+      /* */
       rgba_double_buf_alloc  = babl_malloc (sizeof (double) * n * 4);
       rgba_double_buf        = rgba_double_buf_alloc;
+      rgba_image = babl_image_from_linear (
+          rgba_double_buf, babl_remodel_with_space (babl_model_from_id (BABL_RGBA),
+          BABL (BABL ((babl->fish.source))->format.space)) );
+
+      /* use lcms for doing conversion to RGBA */
+      {
+        double *rgba=rgba_double_buf;
+        double *cmyka=cmyka_double_buf;
+        int i;
+        for (i = 0; i < n; i++)
+        {
+          rgba[i * 4 + 0] = 1.0-cmyka[i * 5 + 0];
+          rgba[i * 4 + 1] = 1.0-cmyka[i * 5 + 1];
+          rgba[i * 4 + 2] = 1.0-cmyka[i * 5 + 2];
+          rgba[i * 4 + 3] = cmyka[i * 5 + 4];
+
+}
+      }
+
+      /* color space conversions */
+       if ((babl_space ("sRGB")!=
+          ((babl->fish.destination)->format.space)))
+      {
+        double matrix[9];
+        double *rgba = rgba_double_buf;
+        babl_matrix_mul_matrix (
+          (babl->fish.destination)->format.space->space.XYZtoRGB,
+          babl_space("sRGB")->space.RGBtoXYZ,
+          matrix);
+
+        babl_matrix_mul_vector_buf4 (matrix, rgba, rgba, n);
+      }
+
+
+
+    /* convert from right double float to target model double rgbish    */
+    {
+      const Babl *destination_rgba_format =
+        babl_remodel_with_space (babl_model_from_id (BABL_RGBA),
+             BABL (BABL ((babl->fish.destination))->format.space));
+
+      if(BABL (babl->fish.destination)->format.model == (void*)destination_rgba_format)
+      {
+         destination_double_buf = rgba_double_buf;
+      }
+      else
+      {
+      Babl *conv =
+        assert_conversion_find (destination_rgba_format,
+           BABL (babl->fish.destination)->format.model);
+         destination_double_buf_alloc = babl_malloc (sizeof (double) * n *
+                                          BABL (babl->fish.destination)->format.model->components);
+         destination_double_buf = destination_double_buf_alloc;
+
+      if (conv->class_type == BABL_CONVERSION_PLANAR)
+        {
+          destination_image = babl_image_from_linear (
+            destination_double_buf, BABL (BABL ((babl->fish.destination))->format.model));
+
+
+          babl_conversion_process (
+            conv,
+            (void*)rgba_image, (void*)destination_image,
+            n);
+        }
+      else if (conv->class_type == BABL_CONVERSION_LINEAR)
+        {
+          babl_conversion_process (
+            conv,
+            rgba_double_buf, destination_double_buf,
+            n);
+        }
+      else babl_fatal ("oops");
+      }
+   }
+
+
     }
     else if (babl->fish.destination->format.space->space.lcms_profile)
     {
@@ -826,6 +903,7 @@ babl_fish_reference_process_double (const Babl *babl,
          then do type conversion and
          component juggling.
        */
+       fprintf (stderr, "need to deal with this\n");
     }
     else
     {
@@ -903,7 +981,6 @@ babl_fish_reference_process_double (const Babl *babl,
       Babl *conv =
         assert_conversion_find (destination_rgba_format,
            BABL (babl->fish.destination)->format.model);
-
          destination_double_buf_alloc = babl_malloc (sizeof (double) * n *
                                           BABL (babl->fish.destination)->format.model->components);
          destination_double_buf = destination_double_buf_alloc;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]