summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorRobin Watts <Robin.Watts@artifex.com>2021-07-12 18:59:21 +0100
committerRobin Watts <Robin.Watts@artifex.com>2021-07-12 18:59:21 +0100
commitae265bfe0f6c8f338e8ede115390ac45d381fd0b (patch)
tree751bf913ef81d83e26af112f4d7f2ab36db02f78 /contrib
parent912aaa0fea22ad1db9c76da7f2f6514e95c6be09 (diff)
downloadghostpdl-ae265bfe0f6c8f338e8ede115390ac45d381fd0b.tar.gz
Bug 703957: Update various contrib devices to use decode/encode_color.
This patch, from Alex Cherepanov, updates the following devices to use decode_color and encode_color rather than relying on the default implementations that lean on the older, obsoleted color mapping functions: cdj670 cdj850 cdj880 cdj890 cdj1600 chp2200 cdnj500 cdj970 lxm3200
Diffstat (limited to 'contrib')
-rw-r--r--contrib/gdevcd8.c50
-rw-r--r--contrib/gdevdj9.c29
-rw-r--r--contrib/gdevlx32.c9
3 files changed, 54 insertions, 34 deletions
diff --git a/contrib/gdevcd8.c b/contrib/gdevcd8.c
index a4d3a0156..e6e9a9420 100644
--- a/contrib/gdevcd8.c
+++ b/contrib/gdevcd8.c
@@ -768,23 +768,39 @@ static void
static void
cdnj500_terminate_page(gx_device_printer * pdev, gp_file * prn_stream);
+/* This decoding to RGB and conversion to CMYK simulates what */
+/* gx_default_decode_color does without calling the map_color_rgb method. */
+static int
+cdj670_compatible_cmyk_decode_color(gx_device *dev, gx_color_index color, gx_color_value cv[4])
+{
+ int i, code = gdev_cmyk_map_color_rgb(dev, color, cv);
+ gx_color_value min_val = gx_max_color_value;
+
+ for (i = 0; i < 3; i++) {
+ if ((cv[i] = gx_max_color_value - cv[i]) < min_val)
+ min_val = cv[i];
+ }
+ for (i = 0; i < 3; i++)
+ cv[i] -= min_val;
+ cv[3] = min_val;
+
+ return code;
+}
+
+
static void
cdj670_initialize_device_procs(gx_device *dev)
{
gdev_prn_initialize_device_procs(dev);
set_dev_proc(dev, open_device, hp_colour_open);
- set_dev_proc(dev, map_rgb_color, NULL);
+ set_dev_proc(dev, map_rgb_color, gx_error_encode_color);
set_dev_proc(dev, map_color_rgb, gdev_cmyk_map_color_rgb);
set_dev_proc(dev, get_params, cdj850_get_params);
set_dev_proc(dev, put_params, cdj850_put_params);
set_dev_proc(dev, map_cmyk_color, gdev_cmyk_map_cmyk_color);
-
- /* The static init used in previous versions of the code leaves
- * encode_color and decode_color set to NULL (which are then rewritten
- * by the system to the default. For compatibility we do the same. */
- set_dev_proc(dev, encode_color, NULL);
- set_dev_proc(dev, decode_color, NULL);
+ set_dev_proc(dev, encode_color, gdev_cmyk_map_cmyk_color);
+ set_dev_proc(dev, decode_color, cdj670_compatible_cmyk_decode_color);
}
static void
@@ -797,13 +813,9 @@ cdj1600_initialize_device_procs(gx_device *dev)
set_dev_proc(dev, map_color_rgb, gdev_pcl_map_color_rgb);
set_dev_proc(dev, get_params, cdj850_get_params);
set_dev_proc(dev, put_params, cdj850_put_params);
- set_dev_proc(dev, map_cmyk_color, NULL);
-
- /* The static init used in previous versions of the code leave
- * encode_color and decode_color set to NULL (which are then rewritten
- * by the system to the default. For compatibility we do the same. */
- set_dev_proc(dev, encode_color, NULL);
- set_dev_proc(dev, decode_color, NULL);
+ set_dev_proc(dev, map_cmyk_color, gx_error_encode_color);
+ set_dev_proc(dev, encode_color, gdev_pcl_map_rgb_color);
+ set_dev_proc(dev, decode_color, gdev_pcl_map_color_rgb);
}
static void
@@ -816,13 +828,9 @@ chp2200_initialize_device_procs(gx_device *dev)
set_dev_proc(dev, map_color_rgb, gx_default_rgb_map_color_rgb);
set_dev_proc(dev, get_params, cdj850_get_params);
set_dev_proc(dev, put_params, cdj850_put_params);
- set_dev_proc(dev, map_cmyk_color, NULL);
-
- /* The static init used in previous versions of the code leave
- * encode_color and decode_color set to NULL (which are then rewritten
- * by the system to the default. For compatibility we do the same. */
- set_dev_proc(dev, encode_color, NULL);
- set_dev_proc(dev, decode_color, NULL);
+ set_dev_proc(dev, map_cmyk_color, gx_error_encode_color);
+ set_dev_proc(dev, encode_color, gx_default_rgb_map_rgb_color);
+ set_dev_proc(dev, decode_color, gx_default_rgb_map_color_rgb);
}
const gx_device_cdj850 gs_cdj670_device =
diff --git a/contrib/gdevdj9.c b/contrib/gdevdj9.c
index 87a62b320..29e668247 100644
--- a/contrib/gdevdj9.c
+++ b/contrib/gdevdj9.c
@@ -510,6 +510,25 @@ typedef struct
terminate_page\
}
+/* This decoding to RGB and conversion to CMYK simulates what */
+/* gx_default_decode_color does without calling the map_color_rgb method. */
+static int
+cdj970_compatible_cmyk_decode_color(gx_device *dev, gx_color_index color, gx_color_value cv[4])
+{
+ int i, code = gdev_cmyk_map_color_rgb(dev, color, cv);
+ gx_color_value min_val = gx_max_color_value;
+
+ for (i = 0; i < 3; i++) {
+ if ((cv[i] = gx_max_color_value - cv[i]) < min_val)
+ min_val = cv[i];
+ }
+ for (i = 0; i < 3; i++)
+ cv[i] -= min_val;
+ cv[3] = min_val;
+
+ return code;
+}
+
static void
cdj970_initialize_device_procs(gx_device *dev)
{
@@ -517,17 +536,13 @@ cdj970_initialize_device_procs(gx_device *dev)
set_dev_proc(dev, open_device, hp_colour_open);
set_dev_proc(dev, close_device, cdj970_close);
- set_dev_proc(dev, map_rgb_color, NULL);
+ set_dev_proc(dev, map_rgb_color, gx_error_encode_color);
set_dev_proc(dev, map_color_rgb, gdev_cmyk_map_color_rgb);
set_dev_proc(dev, get_params, cdj970_get_params);
set_dev_proc(dev, put_params, cdj970_put_params);
set_dev_proc(dev, map_cmyk_color, gdev_cmyk_map_cmyk_color);
-
- /* The static init used in previous versions of the code leave
- * encode_color and decode_color set to NULL (which are then rewritten
- * by the system to the default. For compatibility we do the same. */
- set_dev_proc(dev, encode_color, NULL);
- set_dev_proc(dev, decode_color, NULL);
+ set_dev_proc(dev, encode_color, gdev_cmyk_map_cmyk_color);
+ set_dev_proc(dev, decode_color, cdj970_compatible_cmyk_decode_color);
}
static void
diff --git a/contrib/gdevlx32.c b/contrib/gdevlx32.c
index 6724b6bc9..4471e1a04 100644
--- a/contrib/gdevlx32.c
+++ b/contrib/gdevlx32.c
@@ -267,12 +267,9 @@ lxm3200_initialize_device_procs(gx_device *dev)
set_dev_proc(dev, map_color_rgb, lxm3200_map_color_rgb);
set_dev_proc(dev, get_params, lxm3200_get_params);
set_dev_proc(dev, put_params, lxm3200_put_params);
-
- /* The static init used in previous versions of the code leave
- * encode_color and decode_color set to NULL (which are then rewritten
- * by the system to the default. For compatibility we do the same. */
- set_dev_proc(dev, encode_color, NULL);
- set_dev_proc(dev, decode_color, NULL);
+ set_dev_proc(dev, map_cmyk_color, gx_error_encode_color);
+ set_dev_proc(dev, encode_color, lxm3200_map_rgb_color);
+ set_dev_proc(dev, decode_color, lxm3200_map_color_rgb);
}
/* Define an extension (subclass) of gx_device_printer. */