summaryrefslogtreecommitdiff
path: root/gs/src/zcsindex.c
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2008-08-11 14:16:18 +0000
committerKen Sharp <ken.sharp@artifex.com>2008-08-11 14:16:18 +0000
commitcecbdfcd156a190dfe3bc7ed07e2179cf45dbbb4 (patch)
treea1e8539ea070d84fcd924b0c27b069c5bbe67d0f /gs/src/zcsindex.c
parent91d8f890b4429c3d73f7c28bb1b1ac7a6c3a9751 (diff)
Move the interpretation of PostScript (and PDF) color spaces from PostScript into C.
DETAILS: This has required a large number of changes, there are a few new .c or .h files, a number of PostScript files have been removed, and a few others simplified. A few documentation '.htm' files have also been modified to reflect these changes. EXPECTED DIFFERENCES None git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@8962 a1074d23-0009-0410-80fe-cf8c14f379e6
Diffstat (limited to 'gs/src/zcsindex.c')
-rw-r--r--gs/src/zcsindex.c129
1 files changed, 0 insertions, 129 deletions
diff --git a/gs/src/zcsindex.c b/gs/src/zcsindex.c
index e3cdea33a..2b8f6d9b7 100644
--- a/gs/src/zcsindex.c
+++ b/gs/src/zcsindex.c
@@ -29,135 +29,6 @@
#include "ivmspace.h"
#include "store.h"
-/* Imported from gscolor2.c */
-extern const gs_color_space_type gs_color_space_type_Indexed;
-
-/* Forward references. */
-static int indexed_map1(i_ctx_t *);
-
-/* <array> .setindexedspace - */
-/* The current color space is the base space for the indexed space. */
-static int
-zsetindexedspace(i_ctx_t *i_ctx_p)
-{
- os_ptr op = osp;
- ref *pproc = &istate->colorspace.procs.special.index_proc;
- const ref *pcsa;
- gs_color_space *pcs;
- gs_color_space *pcs_base;
- ref_colorspace cspace_old;
- uint edepth = ref_stack_count(&e_stack);
- int num_entries;
- int code;
-
- check_read_type(*op, t_array);
- if (r_size(op) != 4)
- return_error(e_rangecheck);
- pcsa = op->value.const_refs + 1;
- check_type_only(pcsa[1], t_integer);
- if (pcsa[1].value.intval < 0 || pcsa[1].value.intval > 4095)
- return_error(e_rangecheck);
- num_entries = (int)pcsa[1].value.intval + 1;
- pcs_base = gs_currentcolorspace(igs);
- if (!pcs_base->type->can_be_base_space)
- return_error(e_rangecheck);
- cspace_old = istate->colorspace;
-
- if (r_has_type(&pcsa[2], t_string)) {
- int num_values = num_entries * cs_num_components(pcs_base);
-
- check_read(pcsa[2]);
- /*
- * The PDF and PS specifications state that the lookup table must have
- * the exact number of of data bytes needed. However we have found
- * PDF files from Amyuni with extra data bytes. Acrobat 6.0 accepts
- * these files without complaint, so we ignore the extra data.
- */
- if (r_size(&pcsa[2]) < num_values)
- return_error(e_rangecheck);
- pcs = gs_cspace_alloc(imemory, &gs_color_space_type_Indexed);
- pcs->base_space = pcs_base;
- rc_increment(pcs_base);
- pcs->params.indexed.lookup.table.data = pcsa[2].value.const_bytes;
- pcs->params.indexed.lookup.table.size = num_values;
- pcs->params.indexed.use_proc = 0;
- make_null(pproc);
- code = 0;
- } else {
- gs_indexed_map *map;
-
- check_proc(pcsa[2]);
- /*
- * We have to call zcs_begin_map before moving the parameters,
- * since if the color space is a DeviceN or Separation space,
- * the memmove will overwrite its parameters.
- */
- code = zcs_begin_map(i_ctx_p, &map, &pcsa[2], num_entries,
- pcs_base, indexed_map1);
- if (code < 0)
- return code;
- pcs = gs_cspace_alloc(imemory, &gs_color_space_type_Indexed);
- pcs->base_space = pcs_base;
- rc_increment(pcs_base);
- pcs->params.indexed.use_proc = 1;
- *pproc = pcsa[2];
- map->proc.lookup_index = lookup_indexed_map;
- pcs->params.indexed.lookup.map = map;
- }
- pcs->params.indexed.hival = num_entries - 1;
- pcs->params.indexed.n_comps = cs_num_components(pcs_base);
- code = gs_setcolorspace(igs, pcs);
- /* release reference from construction */
- rc_decrement_only(pcs, "zsetindexedspace");
- if (code < 0) {
- istate->colorspace = cspace_old;
- ref_stack_pop_to(&e_stack, edepth);
- return code;
- }
- pop(1);
- return (ref_stack_count(&e_stack) == edepth ? 0 : o_push_estack); /* installation will load the caches */
-}
-
-/* Continuation procedure for saving mapped Indexed color values. */
-static int
-indexed_map1(i_ctx_t *i_ctx_p)
-{
- os_ptr op = osp;
- es_ptr ep = esp;
- int i = (int)ep[csme_index].value.intval;
-
- if (i >= 0) { /* i.e., not first time */
- int m = (int)ep[csme_num_components].value.intval;
- int code = float_params(op, m, &r_ptr(&ep[csme_map], gs_indexed_map)->values[i * m]);
-
- if (code < 0)
- return code;
- pop(m);
- op -= m;
- if (i == (int)ep[csme_hival].value.intval) { /* All done. */
- esp -= num_csme;
- return o_pop_estack;
- }
- }
- push(1);
- ep[csme_index].value.intval = ++i;
- make_int(op, i);
- make_op_estack(ep + 1, indexed_map1);
- ep[2] = ep[csme_proc]; /* lookup proc */
- esp = ep + 2;
- return o_push_estack;
-}
-
-/* ------ Initialization procedure ------ */
-
-const op_def zcsindex_l2_op_defs[] =
-{
- op_def_begin_level2(),
- {"1.setindexedspace", zsetindexedspace},
- /* Internal operators */
- {"1%indexed_map1", indexed_map1},
- op_def_end(0)
-};
/* ------ Internal routines ------ */