2 |
- |
1 |
/* Copyright (C) 1997, 1998, 1999, 2000 Aladdin Enterprises. All rights reserved.
|
|
|
2 |
|
|
|
3 |
This software is provided AS-IS with no warranty, either express or
|
|
|
4 |
implied.
|
|
|
5 |
|
|
|
6 |
This software is distributed under license and may not be copied,
|
|
|
7 |
modified or distributed except as expressly authorized under the terms
|
|
|
8 |
of the license contained in the file LICENSE in this distribution.
|
|
|
9 |
|
|
|
10 |
For more information about licensing, please refer to
|
|
|
11 |
http://www.ghostscript.com/licensing/. For information on
|
|
|
12 |
commercial licensing, go to http://www.artifex.com/licensing/ or
|
|
|
13 |
contact Artifex Software, Inc., 101 Lucas Valley Road #110,
|
|
|
14 |
San Rafael, CA 94903, U.S.A., +1(415)492-9861.
|
|
|
15 |
*/
|
|
|
16 |
|
|
|
17 |
/* $Id: gstrap.c,v 1.6 2002/06/16 05:48:55 lpd Exp $ */
|
|
|
18 |
/* Setting trapping parameters and zones */
|
|
|
19 |
#include "string_.h"
|
|
|
20 |
#include "gx.h"
|
|
|
21 |
#include "gserrors.h"
|
|
|
22 |
#include "gstrap.h"
|
|
|
23 |
#include "gsparamx.h"
|
|
|
24 |
|
|
|
25 |
/* Put a float parameter. */
|
|
|
26 |
private bool
|
|
|
27 |
check_unit(float *pval)
|
|
|
28 |
{
|
|
|
29 |
return (*pval >= 0 && *pval <= 1);
|
|
|
30 |
}
|
|
|
31 |
private bool
|
|
|
32 |
check_positive(float *pval)
|
|
|
33 |
{
|
|
|
34 |
return (*pval > 0);
|
|
|
35 |
}
|
|
|
36 |
private int
|
|
|
37 |
trap_put_float_param(gs_param_list * plist, gs_param_name param_name,
|
|
|
38 |
float *pval, bool(*check) (float *pval), int ecode)
|
|
|
39 |
{
|
|
|
40 |
int code;
|
|
|
41 |
|
|
|
42 |
switch (code = param_read_float(plist, param_name, pval)) {
|
|
|
43 |
case 0:
|
|
|
44 |
if ((*check) (pval))
|
|
|
45 |
return 0;
|
|
|
46 |
code = gs_error_rangecheck;
|
|
|
47 |
default:
|
|
|
48 |
ecode = code;
|
|
|
49 |
param_signal_error(plist, param_name, ecode);
|
|
|
50 |
break;
|
|
|
51 |
case 1:
|
|
|
52 |
break;
|
|
|
53 |
}
|
|
|
54 |
return ecode;
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
/* settrapparams */
|
|
|
58 |
int
|
|
|
59 |
gs_settrapparams(gs_trap_params_t * pparams, gs_param_list * plist)
|
|
|
60 |
{
|
|
|
61 |
gs_trap_params_t params;
|
|
|
62 |
int ecode = 0;
|
|
|
63 |
static const char *const trap_placement_names[] = {
|
|
|
64 |
gs_trap_placement_names, 0
|
|
|
65 |
};
|
|
|
66 |
|
|
|
67 |
params = *pparams;
|
|
|
68 |
ecode = trap_put_float_param(plist, "BlackColorLimit",
|
|
|
69 |
¶ms.BlackColorLimit, check_unit, ecode);
|
|
|
70 |
ecode = trap_put_float_param(plist, "BlackDensityLimit",
|
|
|
71 |
¶ms.BlackDensityLimit,
|
|
|
72 |
check_positive, ecode);
|
|
|
73 |
ecode = trap_put_float_param(plist, "BlackWidth",
|
|
|
74 |
¶ms.BlackWidth, check_positive, ecode);
|
|
|
75 |
ecode = param_put_bool(plist, "Enabled",
|
|
|
76 |
¶ms.Enabled, ecode);
|
|
|
77 |
ecode = param_put_bool(plist, "ImageInternalTrapping",
|
|
|
78 |
¶ms.ImageInternalTrapping, ecode);
|
|
|
79 |
ecode = param_put_bool(plist, "ImagemaskTrapping",
|
|
|
80 |
¶ms.ImagemaskTrapping, ecode);
|
|
|
81 |
ecode = param_put_int(plist, "ImageResolution",
|
|
|
82 |
¶ms.ImageResolution, ecode);
|
|
|
83 |
if (params.ImageResolution <= 0)
|
|
|
84 |
param_signal_error(plist, "ImageResolution",
|
|
|
85 |
ecode = gs_error_rangecheck);
|
|
|
86 |
ecode = param_put_bool(plist, "ImageToObjectTrapping",
|
|
|
87 |
¶ms.ImageToObjectTrapping, ecode);
|
|
|
88 |
{
|
|
|
89 |
int placement = params.ImageTrapPlacement;
|
|
|
90 |
|
|
|
91 |
ecode = param_put_enum(plist, "ImageTrapPlacement",
|
|
|
92 |
&placement, trap_placement_names, ecode);
|
|
|
93 |
params.ImageTrapPlacement = placement;
|
|
|
94 |
}
|
|
|
95 |
ecode = trap_put_float_param(plist, "SlidingTrapLimit",
|
|
|
96 |
¶ms.SlidingTrapLimit, check_unit, ecode);
|
|
|
97 |
ecode = trap_put_float_param(plist, "StepLimit",
|
|
|
98 |
¶ms.StepLimit, check_unit, ecode);
|
|
|
99 |
ecode = trap_put_float_param(plist, "TrapColorScaling",
|
|
|
100 |
¶ms.TrapColorScaling, check_unit, ecode);
|
|
|
101 |
ecode = trap_put_float_param(plist, "TrapWidth",
|
|
|
102 |
¶ms.TrapWidth, check_positive, ecode);
|
|
|
103 |
if (ecode < 0)
|
|
|
104 |
return ecode;
|
|
|
105 |
*pparams = params;
|
|
|
106 |
return 0;
|
|
|
107 |
}
|