summaryrefslogtreecommitdiff
path: root/doc/sample_downscale_device.htm
blob: d0d5f4d4e0d34385919fbd5c171f55daff9730ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<!doctype html>
<html lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="user-scalable=yes, initial-scale=1, width=device-width">
    <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:200,200i,300,300i,400,400i,600,600i,700,700i,900,900i" rel="stylesheet">
    <link rel="shortcut icon" href="images/favicon.svg">
    <title>Ghostscript: Sample CMYK 32-bit Device that Supports Post Rendering Processing</title>
    <link href="default.css" rel="stylesheet" type="text/css">
</head>

<body>
    <header><div class="title"><a href="index.html"><h1 aria-label="title">Ghostscript documentation</h1><h2 aria-label="version"></h2></a></div><a href="Search.htm" aria-label="Search" id="searchSite"><div class="search"></div></a></header>
    <main>
        <article>
            <div class="outer">

                <div class="inner">
<!--START EDITING HERE-->

<h1>Ghostscript: Sample CMYK 32-bit Device that Supports Post Rendering Processing</h1>

<h2><a name="toc"></a>Table of contents</h2>
<ul class="toc">
    <li><a href="#Description">Description</a>
    <li><a href="#Features">Features</a>
    <li><a href="#devs_mak">Changes to devices/devs.mak</a>
    <li><a href="#Building">Building Ghostscript with the driver</a>
    <li><a href="#Source">Source code</a>
</ul>

<!-- [1.2 end table of contents] =========================================== -->

<!-- [1.3 begin hint] ====================================================== -->

<p>For other information, see the <a href="Drivers.htm">Ghostscript
device drivers</a> and the documentation on <a href="Make.htm">how to build
Ghostscript</a>.

<!-- [1.3 end hint] ======================================================== -->

<hr>

<!-- [1.0 end visible header] ============================================== -->

<!-- [2.0 begin contents] ================================================== -->

<h2><a name="Description"></a>Description</h2>

<p>
This device is a basic CMYK 32-bit (8-bits per component) device that uses the <code>downscaler</code>
features to provide post-rendering operations on the raster data produced by Ghostscript.
<p>
It is designed to allow a developer to add code to handle the resulting raster data
and perform any desired formatting and transmission to some destination, for example
DMA to a printer or sending over a network link.
<p>
<hr>

<h2><a name="Features"></a>Features</h2>

<p>
The <code>downscaler</code> modules provide for the following optional post-rendering
manipulation:

<blockquote><dl>
<dt><code>-dDownScaleFactor=<em>factor</em></code> (small non-negative integer; default = 1)
<dd>If this option set then the page is downscaled by the given factor on both
axes. For example rendering with <tt>-r600</tt> and then specifying <tt>-dDownScaleFactor=3</tt> will produce
a 200dpi image.
<p>
2 additional &quot;special&quot; ratios are available, 32 and 34. 32 provides a 3:2 downscale
(so from 300 to 200 dpi, if the resolution is 300 dpi as with <code>-r300</code>). 34 produces a 3:4 upscale (so from 300 to 400 dpi, similarly).
</dl></blockquote>

<blockquote><dl>
<dt><code>-sPostRenderProfile=<em>path</em></code> (path to an ICC profile)
<dd>If this option set then the page will be color transformed using that
profile <b>after</b> downscaling.
<p>
This is useful when the file uses overprint to separately paint to some
subset of the C, M, Y, and K colorants, but the final CMYK is to be color
corrected for printing or display.
</dl></blockquote>

<p>The <code>ds32</code> device can perform rudimentary automatic 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
slightly extending abutting regions that are rendered in different inks. The
intent of this is to avoid the unsightly gaps that might be otherwise be
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:
<blockquote><dl>
<dt><code>-dTrapX=N</code>
<dd>and
<dt> <code>-dTrapY=N</code>
<dd>(where <code>N</code> is a figure in pixels, <b>before</b> the downscaler is applied).
</dl></blockquote>

<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
this order would be [ 3 1 0 2 ] (K darker than M darker than C darker than Y).
This is the default.

<p>To override these defaults, the <code>TrapOrder</code> parameter can be used. Since
this parameter requires an array, it must be specified using a different method. For
example, if Cyan is darker than Magenta:

<blockquote><code>
    gs -sDEVICE=ds32 -dTrapX=2 -dTrapY=2 -c "&lt;&lt; /TrapOrder [ 3 0 1 2 ] &gt;&gt; setpagedevice" -f examples\colorcir.ps
</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>.

<p>

<p>
<hr>

<h2><a name="devs_mak"></a>Changes to devices/devs.mak</h2>

<p>
The make files used to build Ghostscript use the file devices/devs.mak to
describe what is needed for devices that can be built into the executable,
such as source code files, header files, libraries and dependencies on
other parts of Ghostscript.
<p>
The section below can be added to the end of the devices/devs.mak file:

<blockquote>
<pre>
### -------- Example 32-bit CMYK downscaled device --------------------- ###
# NB: downscale_ is standard in the lib (LIB1s)
&#36;(DD)ds32.dev : &#36;(DEVOBJ)gdevds32.&#36;(OBJ) &#36;(GLD)page.dev \
 &#36;(GDEV) &#36;(DEVS_MAK) &#36;(MAKEDIRS)
        &#36;(SETPDEV2) &#36;(DD)ds32 &#36;(DEVOBJ)gdevds32.&#36;(OBJ)
        &#36;(ADDMOD) &#36;(DD)ds32 -include &#36;(GLD)page

&#36;(DEVOBJ)gdevds32.&#36;(OBJ) : &#36;(DEVSRC)gdevds32.c &#36;(gsicc_cache_h) &#36;(gxdownscale_h) &#36;(AK) \
  &#36;(arch_h) &#36;(gdevprn_h) &#36;(stdio__h)  &#36;(stdint__h) &#36;(DEVS_MAK) &#36;(MAKEDIRS)
        &#36;(DEVCC) &#36;(DEVO_)gdevds32.&#36;(OBJ) &#36;(C_) &#36;(DEVSRC)gdevds32.c
</blockquote>

This snippet is also in a commented block at the top of the source code file.
<p>
<hr>

<h2><a name="Building"></a>Building Ghostscript with the driver</h2>

<p>
The make system also needs to be told to include the <code>ds32</code> device. This can
either be added to the top level make file on one of the <code>DEVICE_DEVS</code> lines,
for example, in <code>psi/msvc.mak</code> for the Windows build:
<blockquote>
<pre>
DEVICE_DEVS21=$(DD)ds32.dev $(DD)spotcmyk.dev $(DD)devicen.dev $(DD)bmpsep1.dev $(DD)bmpsep8.dev $(DD)bmp16m.dev $(DD)bmp32b.dev $(DD)psdcmyk.dev $(DD)psdrgb.dev $(DD)cp50.dev $(DD)gprf.dev
</blockquote>

Rather than editing a make file, there is a convenient macro that allows the extra device
to be added to the build command line, <code>DEVICE_DEVS_EXTRA</code>. For example, on
linux:
<blockquote>
<pre>
make DEVICE_DEVS_EXTRA=obj/ds32.dev
</blockquote>
or, on Windows:
<blockquote>
<pre>
nmake -f psi/msvc32.mak DEVICE_DEVS_EXTRA=obj\ds32.dev
</blockquote>
<hr>

<h2><a name="Source"></a>Source code</h2>

<p>
The source for this device driver is in: <a href="gdevds32.c">doc/gdevds32.c</a>

<p>
<hr>

<!-- [2.0 end contents] ==================================================== -->

<!-- [3.0 begin visible trailer] =========================================== -->

<p>
  <small>Copyright &copy; 2016-2022 Artifex Software, Inc.  All rights reserved.</small>

<p>
This software is provided AS-IS with no warranty, either express or
implied.

This software is distributed under license and may not be copied, modified
or distributed except as expressly authorized under the terms of that
license.  Refer to licensing information at <a href="https://www.artifex.com">https://www.artifex.com</a>
or contact Artifex Software, Inc.,  1305 Grant Avenue - Suite 200,
Novato, CA 94945, U.S.A., +1(415)492-9861, for further information.

<p>
<small>Ghostscript version 9.56.0, 29 March 2022

<!-- [3.0 end visible trailer] ============================================= -->

<!--FINISH EDITING HERE-->
          </div><!-- close inner -->
        </div><!-- close outer -->
      </article>
    </main>
    <script src="site.js"></script>
</body>
</html>