|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T z
Length: 4230 (0x1086) Types: TextFile Names: »zpaint.c«
└─⟦a05ed705a⟧ Bits:30007078 DKUUG GNU 2/12/89 └─⟦ff23ba0e6⟧ »./ghostscript-1.3.tar.Z« └─⟦a24a58cd3⟧ └─⟦this⟧ »zpaint.c«
/* Copyright (C) 1989 Aladdin Enterprises. All rights reserved. Distributed by Free Software Foundation, Inc. This file is part of Ghostscript. Ghostscript is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. No author or distributor accepts responsibility to anyone for the consequences of using it or for whether it serves any particular purpose or works at all, unless he says so in writing. Refer to the Ghostscript General Public License for full details. Everyone is granted permission to copy, modify and redistribute Ghostscript, but only under the conditions described in the Ghostscript General Public License. A copy of this license is supposed to have been given to you along with Ghostscript so you can know your rights and responsibilities. It should be in a file named COPYING. Among other things, the copyright notice and this notice must be preserved on all copies. */ /* zpaint.c */ /* Painting operators for GhostScript */ #include "ghost.h" #include "errors.h" #include "oper.h" #include "alloc.h" #include "estack.h" /* for image[mask] */ #include "store.h" #include "gsmatrix.h" #include "gspaint.h" #include "state.h" /* Forward references */ private int image_setup(P3(ref *, int, int (*)(P6(gs_image_enum *, gs_state *, int, int, int, gs_matrix *)))); private int image_continue(P1(ref *)); /* erasepage */ int zerasepage(register ref *op) { return gs_erasepage(igs); } /* fill */ int zfill(register ref *op) { return gs_fill(igs); } /* eofill */ int zeofill(register ref *op) { return gs_eofill(igs); } /* stroke */ int zstroke(register ref *op) { return gs_stroke(igs); } /* image */ int zimage(register ref *op) { check_type(op[-2], t_integer); /* bits/sample */ if ( (ulong)(op[-2].value.intval) > 8 ) return e_rangecheck; return image_setup(op, (int)op[-2].value.intval, gs_image_init); } /* imagemask */ int zimagemask(register ref *op) { check_type(op[-2], t_boolean); return image_setup(op, op[-2].value.index, gs_imagemask_init); } /* Common setup for image and imagemask. */ private int image_setup(ref *op, int param3 /* bits/sample or invert */, int (*pinit)(P6(gs_image_enum *, gs_state *, int, int, int, gs_matrix *))) { int code; gs_image_enum *penum; gs_matrix mat; /* We push on the estack: */ /* Control mark, proc, enumeration structure (as bytes). */ #define inumpush 3 #define iproc esp[-1] check_estack(inumpush + 2); /* stuff above, + continuation + proc */ check_type(op[-4], t_integer); /* width */ check_type(op[-3], t_integer); /* height */ check_proc(*op); /* proc */ if ( op[-4].value.intval <= 0 || op[-3].value.intval < 0 ) return e_undefinedresult; if ( op[-3].value.intval == 0 ) return 0; /* empty image */ if ( (code = read_matrix(op - 1, &mat)) < 0 ) return code; if ( (penum = (gs_image_enum *)alloc(gs_image_enum_sizeof, "image_setup")) == 0 ) return e_VMerror; code = (*pinit)(penum, igs, (int)op[-4].value.intval, (int)op[-3].value.intval, param3, &mat); if ( code < 0 ) return code; mark_estack(es_other); *++esp = *op; /* proc */ ++esp; make_tasv(esp, t_string, 0, gs_image_enum_sizeof, bytes, (byte *)penum); #ifdef DEBUG if ( gs_debug['b'] ) printf("Image: w=%d h=%d\n", (int)op[-4].value.intval, (int)op[-3].value.intval); #endif push_op_estack(image_continue); *++esp = *op; /* run the procedure */ pop(5); return o_check_estack; } /* Continuation procedure. Hand the string to the enumerator. */ private int image_continue(register ref *op) { int code; if ( r_type(op) != t_string ) { /* Procedure didn't return a string. Quit. */ esp -= inumpush; return e_typecheck; } code = gs_image_next((gs_image_enum *)esp->value.bytes, op->value.bytes, op->size); if ( op->size == 0 || code > 0 ) /* stop now */ { esp -= inumpush; } else { ref *pproc = esp - 1; push_op_estack(image_continue); *++esp = *pproc; } pop(1); return o_check_estack; } /* ------ Initialization procedure ------ */ void zpaint_op_init() { static op_def my_defs[] = { {"0eofill", zeofill}, {"0erasepage", zerasepage}, {"0fill", zfill}, {"5image", zimage}, {"5imagemask", zimagemask}, {"0stroke", zstroke}, op_def_end }; z_op_init(my_defs); }