1 /* Copyright (C) 1997, 1998, 1999 artofcode LLC.  All rights reserved.
2 
3   This program is free software; you can redistribute it and/or modify it
4   under the terms of the GNU General Public License as published by the
5   Free Software Foundation; either version 2 of the License, or (at your
6   option) any later version.
7 
8   This program is distributed in the hope that it will be useful, but
9   WITHOUT ANY WARRANTY; without even the implied warranty of
10   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11   General Public License for more details.
12 
13   You should have received a copy of the GNU General Public License along
14   with this program; if not, write to the Free Software Foundation, Inc.,
15   59 Temple Place, Suite 330, Boston, MA, 02111-1307.
16 
17 */
18 
19 /*$Id: zpaint.c,v 1.2.6.1.2.1 2003/01/17 00:49:06 giles Exp $ */
20 /* Painting operators */
21 #include "ghost.h"
22 #include "oper.h"
23 #include "gspaint.h"
24 #include "igstate.h"
25 
26 /* - fill - */
27 private int
zfill(i_ctx_t * i_ctx_p)28 zfill(i_ctx_t *i_ctx_p)
29 {
30     return gs_fill(igs);
31 }
32 
33 /* - eofill - */
34 private int
zeofill(i_ctx_t * i_ctx_p)35 zeofill(i_ctx_t *i_ctx_p)
36 {
37     return gs_eofill(igs);
38 }
39 
40 /* - stroke - */
41 private int
zstroke(i_ctx_t * i_ctx_p)42 zstroke(i_ctx_t *i_ctx_p)
43 {
44     return gs_stroke(igs);
45 }
46 
47 /* ------ Non-standard operators ------ */
48 
49 /* - .fillpage - */
50 private int
zfillpage(i_ctx_t * i_ctx_p)51 zfillpage(i_ctx_t *i_ctx_p)
52 {
53     return gs_fillpage(igs);
54 }
55 
56 /* <width> <height> <data> .imagepath - */
57 private int
zimagepath(i_ctx_t * i_ctx_p)58 zimagepath(i_ctx_t *i_ctx_p)
59 {
60     os_ptr op = osp;
61     int code;
62 
63     check_type(op[-2], t_integer);
64     check_type(op[-1], t_integer);
65     check_read_type(*op, t_string);
66     if (r_size(op) < ((op[-2].value.intval + 7) >> 3) * op[-1].value.intval)
67 	return_error(e_rangecheck);
68     code = gs_imagepath(igs,
69 			(int)op[-2].value.intval, (int)op[-1].value.intval,
70 			op->value.const_bytes);
71     if (code >= 0)
72 	pop(3);
73     return code;
74 }
75 
76 /* ------ Initialization procedure ------ */
77 
78 const op_def zpaint_op_defs[] =
79 {
80     {"0eofill", zeofill},
81     {"0fill", zfill},
82     {"0stroke", zstroke},
83 		/* Non-standard operators */
84     {"0.fillpage", zfillpage},
85     {"3.imagepath", zimagepath},
86     op_def_end(0)
87 };
88