xref: /plan9/sys/src/cmd/gs/src/zcspixel.c (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 1997, 1998, 1999 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: zcspixel.c,v 1.5 2004/08/04 19:36:13 stefan Exp $ */
18 /* DevicePixel color space support */
19 #include "ghost.h"
20 #include "oper.h"
21 #include "igstate.h"
22 #include "gscspace.h"
23 #include "gsmatrix.h"		/* for gscolor2.h */
24 #include "gscolor2.h"
25 #include "gscpixel.h"
26 #include "ialloc.h"
27 
28 /* <array> .setdevicepixelspace - */
29 private int
zsetdevicepixelspace(i_ctx_t * i_ctx_p)30 zsetdevicepixelspace(i_ctx_t *i_ctx_p)
31 {
32     os_ptr op = osp;
33     ref depth;
34     gs_color_space cs;
35     int code;
36 
37     check_read_type(*op, t_array);
38     if (r_size(op) != 2)
39 	return_error(e_rangecheck);
40     array_get(imemory, op, 1L, &depth);
41     check_type_only(depth, t_integer);
42     code = gs_cspace_init_DevicePixel(imemory, &cs, (int)depth.value.intval);
43     if (code < 0)
44 	return code;
45     code = gs_setcolorspace(igs, &cs);
46     if (code >= 0)
47 	pop(1);
48     return code;
49 }
50 
51 /* ------ Initialization procedure ------ */
52 
53 const op_def zcspixel_op_defs[] =
54 {
55     {"1.setdevicepixelspace", zsetdevicepixelspace},
56     op_def_end(0)
57 };
58