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
|
/* Copyright (C) 2001-2006 Artifex Software, Inc.
All Rights Reserved.
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 http://www.artifex.com/
or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
*/
/* $Id$ */
/* Setting trapping parameters and zones */
#include "string_.h"
#include "gx.h"
#include "gserrors.h"
#include "gstrap.h"
#include "gsparamx.h"
/* Put a float parameter. */
static bool
check_unit(float *pval)
{
return (*pval >= 0 && *pval <= 1);
}
static bool
check_positive(float *pval)
{
return (*pval > 0);
}
static int
trap_put_float_param(gs_param_list * plist, gs_param_name param_name,
float *pval, bool(*check) (float *pval), int ecode)
{
int code;
switch (code = param_read_float(plist, param_name, pval)) {
case 0:
if ((*check) (pval))
return 0;
code = gs_error_rangecheck;
default:
ecode = code;
param_signal_error(plist, param_name, ecode);
break;
case 1:
break;
}
return ecode;
}
/* settrapparams */
int
gs_settrapparams(gs_trap_params_t * pparams, gs_param_list * plist)
{
gs_trap_params_t params;
int ecode = 0;
static const char *const trap_placement_names[] = {
gs_trap_placement_names, 0
};
params = *pparams;
ecode = trap_put_float_param(plist, "BlackColorLimit",
¶ms.BlackColorLimit, check_unit, ecode);
ecode = trap_put_float_param(plist, "BlackDensityLimit",
¶ms.BlackDensityLimit,
check_positive, ecode);
ecode = trap_put_float_param(plist, "BlackWidth",
¶ms.BlackWidth, check_positive, ecode);
ecode = param_put_bool(plist, "Enabled",
¶ms.Enabled, ecode);
ecode = param_put_bool(plist, "ImageInternalTrapping",
¶ms.ImageInternalTrapping, ecode);
ecode = param_put_bool(plist, "ImagemaskTrapping",
¶ms.ImagemaskTrapping, ecode);
ecode = param_put_int(plist, "ImageResolution",
¶ms.ImageResolution, ecode);
if (params.ImageResolution <= 0)
param_signal_error(plist, "ImageResolution",
ecode = gs_error_rangecheck);
ecode = param_put_bool(plist, "ImageToObjectTrapping",
¶ms.ImageToObjectTrapping, ecode);
{
int placement = params.ImageTrapPlacement;
ecode = param_put_enum(plist, "ImageTrapPlacement",
&placement, trap_placement_names, ecode);
params.ImageTrapPlacement = placement;
}
ecode = trap_put_float_param(plist, "SlidingTrapLimit",
¶ms.SlidingTrapLimit, check_unit, ecode);
ecode = trap_put_float_param(plist, "StepLimit",
¶ms.StepLimit, check_unit, ecode);
ecode = trap_put_float_param(plist, "TrapColorScaling",
¶ms.TrapColorScaling, check_unit, ecode);
ecode = trap_put_float_param(plist, "TrapWidth",
¶ms.TrapWidth, check_positive, ecode);
if (ecode < 0)
return ecode;
*pparams = params;
return 0;
}
|