diff options
author | Robin Watts <robin.watts@artifex.com> | 2016-02-03 12:48:07 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2016-02-05 15:47:25 +0000 |
commit | 15f8b6ce6d7ae574d7803bb19d2f5cec474f087b (patch) | |
tree | 3fa6611c38283b364ce73f6ef7ceffc1b9d89556 | |
parent | afc7e2cfb9544a8cebd8abb0d89e02429ad98f7d (diff) | |
download | ghostpdl-15f8b6ce6d7ae574d7803bb19d2f5cec474f087b.tar.gz |
Disable trapping by default.
Build with ENABLE_TRAPPING to reenable it. Add explanation and
warnings to doc/Devices.htm.
-rw-r--r-- | base/gxdownscale.c | 100 | ||||
-rw-r--r-- | doc/Devices.htm | 34 |
2 files changed, 86 insertions, 48 deletions
diff --git a/base/gxdownscale.c b/base/gxdownscale.c index 0cf052ad9..489f10a20 100644 --- a/base/gxdownscale.c +++ b/base/gxdownscale.c @@ -1595,6 +1595,57 @@ static int get_planar_line_for_trap(void *arg, unsigned char *buf) return code; } +static int check_trapping(gs_memory_t *memory, int trap_w, int trap_h, + int num_comps, const int *comp_order) +{ +#ifndef ENABLE_TRAPPING + if (trap_w > 0 || trap_h > 0) + { + dmprintf(memory, + "Trapping is disabled in this build. To enable trapping,\n" + "follow the instructions in the documentation. Please note\n" + "that if you do this, you are responsible for ensuring that\n" + "you have any and all patent licenses that may be required.\n"); + return gs_error_rangecheck; + } +#endif + + if (trap_w < 0 || trap_h < 0) + { + dmprintf(memory, "Trapping range must be >= 0"); + return gs_error_rangecheck; + } + + if (trap_w > 0 || trap_h > 0) + { + if (comp_order == NULL) + { + emprintf(memory, "Trapping cannot be used without comp_order being defined"); + return gs_error_rangecheck; + } + + /* Check that the comp_order we have been passed is sane */ + { + char comps[GS_CLIENT_COLOR_MAX_COMPONENTS] = { 0 }; + int i; + + for (i = 0; i < num_comps; i++) + { + int n = comp_order[i]; + if (n < 0 || n >= num_comps || comps[n] != 0) + break; + comps[n] = 1; + } + if (i != num_comps) + { + emprintf(memory, "Illegal component order passed to trapping"); + return gs_error_rangecheck; + } + } + } + return 0; +} + int gx_downscaler_init_planar(gx_downscaler_t *ds, gx_device *dev, gs_get_bits_params_t *params, @@ -1642,20 +1693,12 @@ int gx_downscaler_init_planar_trapped(gx_downscaler_t *ds, ds->scaled_data = NULL; ds->scaled_span = bitmap_raster((dst_bpc*dev->width*upfactor + downfactor-1)/downfactor); - if (trap_w < 0 || trap_h < 0) - { - dmprintf(dev->memory, "Trapping range must be >= 0"); - return gs_error_rangecheck; - } + code = check_trapping(dev->memory, trap_w, trap_h, num_comps, comp_order); + if (code < 0) + return code; if (trap_w > 0 || trap_h > 0) { - if (comp_order == NULL) - { - dmprintf(dev->memory, "Trapping cannot be used without comp_order being defined"); - return gs_error_rangecheck; - } - ds->claptrap = ClapTrap_Init(dev->memory, width, dev->height, num_comps, comp_order, trap_w, trap_h, get_planar_line_for_trap, ds); if (ds->claptrap == NULL) { @@ -1828,40 +1871,13 @@ int gx_downscaler_init_trapped(gx_downscaler_t *ds, ds->factor = factor; ds->num_planes = 0; ds->src_bpc = src_bpc; - - if (trap_w < 0 || trap_h < 0) - { - dmprintf(dev->memory, "Trapping range must be >= 0"); - return gs_error_rangecheck; - } + + code = check_trapping(dev->memory, trap_w, trap_h, num_comps, comp_order); + if (code < 0) + return code; if (trap_w > 0 || trap_h > 0) { - if (comp_order == NULL) - { - emprintf(dev->memory, "Trapping cannot be used without comp_order being defined"); - return gs_error_rangecheck; - } - - /* Check that the comp_order we have been passed is sane */ - { - char comps[GS_CLIENT_COLOR_MAX_COMPONENTS] = { 0 }; - int i; - - for (i = 0; i < num_comps; i++) - { - int n = comp_order[i]; - if (n < 0 || n >= num_comps || comps[n] != 0) - break; - comps[n] = 1; - } - if (i != num_comps) - { - emprintf(dev->memory, "Illegal component order passed to trapping"); - return gs_error_rangecheck; - } - } - ds->claptrap = ClapTrap_Init(dev->memory, width, dev->height, num_comps, comp_order, trap_w, trap_h, get_line_for_trap, ds); if (ds->claptrap == NULL) { diff --git a/doc/Devices.htm b/doc/Devices.htm index 5694b708e..60339dc3d 100644 --- a/doc/Devices.htm +++ b/doc/Devices.htm @@ -731,7 +731,8 @@ to 32760. <p>The <code>tiffsep</code> device (along with the <code>tiffscaled32</code> and <code>psdcmyk</code> devices) can perform rudimentary automatic bitmap -'trapping' on the final rendered bitmap. +'trapping' on the final rendered bitmap. This code is disabled by default; see +the <a href="trapping_patent_note">note</a> below as to why. <p>Trapping is a process whereby the output is adjusted to minimise the visual impact of offsets between each printed plane. Typically this involves @@ -741,8 +742,8 @@ revealed in the final printout if the different color plates do not exactly line up. <p>This trapping is controlled by 3 device parameters. Firstly the maximum -X and Y offsets are specified using <tt>-dTrapX=N</tt> and <tt>-dTrapY=N</tt> (where <tt>N</tt> is a -figure in pixels, before the downscaler is applied). +X and Y offsets are specified using <tt>-dTrapX=N</tt> and <tt>-dTrapY=N</tt> +(where <tt>N</tt> is a figure in pixels, before the downscaler is applied). <p>The final control is to inform the trapping process in what order inks should be processed, from darkest to lightest. For a typical CMYK device @@ -757,7 +758,27 @@ example: <blockquote><code> gs -sDEVICE=psdcmyk -dTrapX=2 -dTrapY=2 -o out.psd -c "<< [ 4 5 3 1 0 2 ] >> setpagedevice" -f examples\tiger.eps </code></blockquote> - + +<h4><a name="trapping_patent_note"></a>Trapping patents</h4> + +<p>Trapping is an technology area encumbered by many patents. Until +we can convince ourselves that our trapping code is not covered by +any of these patents, the functionality is disabled by default.</p> + +<p>It can be enabled by building with the <tt>ENABLE_TRAPPING</tt> +define, but before you do so you should convince yourself that +either:</p> + +<ul> +<li>The trapping code is not covered by any existing patent. +<li>Any patents that do cover the code are invalid in your +jurisdiction. +<li>That you have appropriate patent licenses for any patents + that do apply. +</ul> + +<p>You bear full responsibility for choosing to build with +<tt>ENABLE_TRAPPING</tt>. <h3><a name="fax"></a>FAX</h3> @@ -804,8 +825,9 @@ colors. <a href="#tiffsep">See the comments under the <tt>tiffsep</tt> and <tt> device about the maximum number of spot colors supported by Ghostscript</a> <p> -These devices support the same -dDownScaleFactor= ratios as <tt>tiffsep</tt>. <tt>tiffscaled32</tt> -supports the same trapping options as <tt>tiffsep</tt>. +These devices support the same -dDownScaleFactor= ratios as <tt>tiffsep</tt>. +<tt>psdcmyk</tt> supports the same trapping options as <tt>tiffsep</tt> +(but see <a href="trapping_patent_note">this note</a>). <p> NOTE: The PSD format is a single image per file format, so you must use the "%d" |