/* Copyright (C) 1989, 1991 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
/* Halftone operators and rendering for Ghostscript */
private int screen_sample(P1(os_ptr
));
private int set_screen_continue(P1(os_ptr
));
private int i_set_screen_continue
;
/* currenthalftonephase */
zcurrenthalftonephase(register os_ptr op
)
gs_currenthalftonephase(igs
, &phase
);
make_int(op
- 1, phase
.x
);
zcurrentscreen(register os_ptr op
)
float (*proc
)(P2(floatp
, floatp
));
gs_currentscreen(igs
, &freq
, &angle
, &proc
);
make_real(op
- 1, angle
);
*op
= istate
.screen_proc
;
zsethalftonephase(register os_ptr op
)
check_type(op
[-1], t_integer
);
check_type(*op
, t_integer
);
if ( x
!= (int)x
|| y
!= (int)y
)
code
= gs_sethalftonephase(igs
, (int)x
, (int)y
);
/* The setscreen operator is complex because it has to sample */
/* each pixel in the pattern cell, calling a procedure, and then */
/* sort the result into a whitening order. */
/* Layout of stuff pushed on estack: */
/* enumeration structure (as bytes). */
#define senum (gs_screen_enum *)esp->value.bytes
zsetscreen(register os_ptr op
)
int code
= num_params(op
- 1, 2, fa
);
if ( code
< 0 ) return code
;
penum
= (gs_screen_enum
*)alloc(1, gs_screen_enum_sizeof
, "setscreen");
if ( penum
== 0 ) return e_VMerror
;
code
= gs_screen_init(penum
, igs
, fa
[0], fa
[1]);
{ alloc_free((char *)penum
, 1, gs_screen_enum_sizeof
, "setscreen");
/* Push everything on the estack */
*++esp
= *op
; /* sproc = proc */
make_tasv(esp
, t_string
, 0, gs_screen_enum_sizeof
, bytes
, (byte
*)penum
);
return screen_sample(op
);
/* Set up the next sample */
screen_sample(register os_ptr op
)
{ gs_screen_enum
*penum
= senum
;
int code
= gs_screen_currentpoint(penum
, &pt
);
if ( code
< 0 ) return code
;
istate
.screen_proc
= sproc
;
push_op_estack(set_screen_continue
, i_set_screen_continue
);
/* Continuation procedure for processing sampled pixels. */
set_screen_continue(register os_ptr op
)
int code
= num_params(op
, 1, &value
);
if ( code
< 0 ) return code
;
code
= gs_screen_next(senum
, value
);
if ( code
< 0 ) return code
;
return screen_sample(op
);
/* ------ Initialization procedure ------ */
{"0currenthalftonephase", zcurrenthalftonephase
},
{"0currentscreen", zcurrentscreen
},
{"2sethalftonephase", zsethalftonephase
},
{"3setscreen", zsetscreen
},
{"1%set_screen_continue", set_screen_continue
, &i_set_screen_continue
},