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
|
/* Copyright (C) 1997, 1998, 1999 Aladdin Enterprises. All rights reserved.
This file is part of Aladdin Ghostscript.
Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author
or distributor accepts any responsibility for the consequences of using it,
or for whether it serves any particular purpose or works at all, unless he
or she says so in writing. Refer to the Aladdin Ghostscript Free Public
License (the "License") for full details.
Every copy of Aladdin Ghostscript must include a copy of the License,
normally in a plain ASCII text file named PUBLIC. The License grants you
the right to copy, modify and redistribute Aladdin Ghostscript, but only
under certain conditions described in the License. Among other things, the
License requires that the copyright notice and this notice be preserved on
all copies.
*/
/* PostScript language interface to LL3 Functions */
#include "memory_.h"
#include "ghost.h"
#include "oper.h"
#include "gsfunc3.h"
#include "gsstruct.h"
#include "stream.h" /* for files.h */
#include "files.h"
#include "ialloc.h"
#include "idict.h"
#include "idparam.h"
#include "ifunc.h"
#include "store.h"
/* Define the available Function types. */
/* Finish building a FunctionType 2 (ExponentialInterpolation) function. */
int
gs_build_function_2(const ref *op, const gs_function_params_t * mnDR,
int depth, gs_function_t ** ppfn)
{
gs_function_ElIn_params_t params;
int code, n0, n1;
*(gs_function_params_t *)¶ms = *mnDR;
params.C0 = 0;
params.C1 = 0;
if ((code = dict_float_param(op, "N", 0.0, ¶ms.N)) != 0 ||
(code = n0 = fn_build_float_array(op, "C0", false, false, ¶ms.C0)) < 0 ||
(code = n1 = fn_build_float_array(op, "C1", false, false, ¶ms.C1)) < 0
)
goto fail;
if (params.C0 == 0)
n0 = 1; /* C0 defaulted */
if (params.C1 == 0)
n1 = 1; /* C1 defaulted */
if (params.Range == 0)
params.n = n0; /* either one will do */
if (n0 != n1 || n0 != params.n)
goto fail;
code = gs_function_ElIn_init(ppfn, ¶ms, imemory);
if (code >= 0)
return 0;
fail:
gs_function_ElIn_free_params(¶ms, imemory);
return (code < 0 ? code : gs_note_error(e_rangecheck));
}
/* Finish building a FunctionType 3 (1-Input Stitching) function. */
int
gs_build_function_3(const ref *op, const gs_function_params_t * mnDR,
int depth, gs_function_t ** ppfn)
{
gs_function_1ItSg_params_t params;
int code;
*(gs_function_params_t *) & params = *mnDR;
params.Functions = 0;
params.Bounds = 0;
params.Encode = 0;
{
ref *pFunctions;
gs_function_t **ptr;
int i;
if ((code = dict_find_string(op, "Functions", &pFunctions)) <= 0)
return (code < 0 ? code : gs_note_error(e_rangecheck));
check_array_only(*pFunctions);
params.k = r_size(pFunctions);
code = ialloc_function_array(params.k, &ptr);
if (code < 0)
return code;
params.Functions = (const gs_function_t * const *)ptr;
for (i = 0; i < params.k; ++i) {
ref subfn;
array_get(pFunctions, (long)i, &subfn);
code = fn_build_sub_function(&subfn, &ptr[i], depth);
if (code < 0)
goto fail;
}
}
if ((code = fn_build_float_array(op, "Bounds", true, false, ¶ms.Bounds)) != params.k - 1 ||
(code = fn_build_float_array(op, "Encode", true, true, ¶ms.Encode)) != 2 * params.k
)
goto fail;
if (params.Range == 0)
params.n = params.Functions[0]->params.n;
code = gs_function_1ItSg_init(ppfn, ¶ms, imemory);
if (code >= 0)
return 0;
fail:
gs_function_1ItSg_free_params(¶ms, imemory);
return (code < 0 ? code : gs_note_error(e_rangecheck));
}
|