xref: /plan9/sys/src/cmd/gs/src/zpaint.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: zpaint.c,v 1.4 2002/02/21 22:24:54 giles Exp $ */
18 /* Painting operators */
19 #include "ghost.h"
20 #include "oper.h"
21 #include "gspaint.h"
22 #include "igstate.h"
23 
24 /* - fill - */
25 private int
zfill(i_ctx_t * i_ctx_p)26 zfill(i_ctx_t *i_ctx_p)
27 {
28     return gs_fill(igs);
29 }
30 
31 /* - eofill - */
32 private int
zeofill(i_ctx_t * i_ctx_p)33 zeofill(i_ctx_t *i_ctx_p)
34 {
35     return gs_eofill(igs);
36 }
37 
38 /* - stroke - */
39 private int
zstroke(i_ctx_t * i_ctx_p)40 zstroke(i_ctx_t *i_ctx_p)
41 {
42     return gs_stroke(igs);
43 }
44 
45 /* ------ Non-standard operators ------ */
46 
47 /* - .fillpage - */
48 private int
zfillpage(i_ctx_t * i_ctx_p)49 zfillpage(i_ctx_t *i_ctx_p)
50 {
51     return gs_fillpage(igs);
52 }
53 
54 /* <width> <height> <data> .imagepath - */
55 private int
zimagepath(i_ctx_t * i_ctx_p)56 zimagepath(i_ctx_t *i_ctx_p)
57 {
58     os_ptr op = osp;
59     int code;
60 
61     check_type(op[-2], t_integer);
62     check_type(op[-1], t_integer);
63     check_read_type(*op, t_string);
64     if (r_size(op) < ((op[-2].value.intval + 7) >> 3) * op[-1].value.intval)
65 	return_error(e_rangecheck);
66     code = gs_imagepath(igs,
67 			(int)op[-2].value.intval, (int)op[-1].value.intval,
68 			op->value.const_bytes);
69     if (code >= 0)
70 	pop(3);
71     return code;
72 }
73 
74 /* ------ Initialization procedure ------ */
75 
76 const op_def zpaint_op_defs[] =
77 {
78     {"0eofill", zeofill},
79     {"0fill", zfill},
80     {"0stroke", zstroke},
81 		/* Non-standard operators */
82     {"0.fillpage", zfillpage},
83     {"3.imagepath", zimagepath},
84     op_def_end(0)
85 };
86