[babl/wip/pippin/inverted-cmyk: 3/4] reference: some cmyk based to rgb based formats go through pipeline, but cmyk to rgb is missing
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl/wip/pippin/inverted-cmyk: 3/4] reference: some cmyk based to rgb based formats go through pipeline, but cmyk to rgb is missing
- Date: Fri, 9 Nov 2018 01:07:49 +0000 (UTC)
commit da04f7d4b9c62f9f904f390e912c82bd12fa41c1
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 | 104 +++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 100 insertions(+), 4 deletions(-)
---
diff --git a/babl/babl-fish-reference.c b/babl/babl-fish-reference.c
index 8b7adc1..1c42de6 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;
@@ -811,11 +811,105 @@ 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)) );
+
+#if HAVE_LCMS
+ /* use lcms for doing conversion to RGBA */
+
+ if(1)
+ {
+ double *cmyka=cmyka_double_buf;
+ int i;
+ for (i = 0; i < n; i++)
+ {
+ cmyka[i * 5 + 0] = (1.0-cmyka[i * 5 + 0])*100.0;
+ cmyka[i * 5 + 1] = (1.0-cmyka[i * 5 + 1])*100.0;
+ cmyka[i * 5 + 2] = (1.0-cmyka[i * 5 + 2])*100.0;
+ cmyka[i * 5 + 3] = (1.0-cmyka[i * 5 + 3])*100.0;
+ }
+ }
+ cmsDoTransform (babl->fish.source->format.space->space.lcms_to_rgba,
+ cmyka_double_buf, rgba_double_buf, n);
+
+#else
+ {
+ double *rgba=rgba_double_buf;
+ double *cmyka=cmyka_double_buf;
+ int i;
+ for (i = 0; i < n; i++)
+ {
+ /* not a proper conversion at all - but it is something */
+ rgba[i * 4 + 0] = cmyka[i * 5 + 0]*cmyka[i*5+3];
+ rgba[i * 4 + 1] = cmyka[i * 5 + 1]*cmyka[i*5+3];
+ rgba[i * 4 + 2] = cmyka[i * 5 + 2]*cmyka[i*5+3];
+ rgba[i * 4 + 3] = cmyka[i * 5 + 4];
+}
+ }
+#endif
+}
+
+ /* 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 +920,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 +998,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;
@@ -1372,6 +1466,8 @@ babl_fish_reference_process (const Babl *babl,
babl->fish.destination->format.space->space.lcms_profile
)
{
+ babl_fish_reference_process_double (babl, source, destination, n, data);
+ return;
}
if (allow_float_reference == -1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]