1 /* Copyright (C) 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: gshtx.h,v 1.6 2002/08/22 07:12:29 henrys Exp $ */ 18 /* High-level interface to stand-alone halftone/transfer objects */ 19 20 #ifndef gshtx_INCLUDED 21 # define gshtx_INCLUDED 22 23 #include "gsmemory.h" 24 #include "gsht1.h" 25 #include "gxtmap.h" 26 #include "gscspace.h" 27 28 /* 29 * The stand-alone halftone structures are opaque, and are placed in an opaque 30 * graphic state. 31 */ 32 33 /* Alias type names */ 34 #define gs_ht gs_halftone 35 #define gs_spot_ht gs_spot_halftone 36 #define gs_threshold_ht gs_threshold_halftone 37 #define gs_ht_component gs_halftone_component 38 #define gs_multiple_ht gs_multiple_halftone 39 /* Alias GC descriptors */ 40 #define st_gs_ht st_halftone 41 #define st_ht_comp_element st_ht_component_element 42 /* Alias member names */ 43 #define ht_spot spot 44 #define ht_threshold threshold 45 #define ht_multiple multiple 46 47 #ifndef gs_state_DEFINED 48 # define gs_state_DEFINED 49 typedef struct gs_state_s gs_state; 50 51 #endif 52 53 /* 54 * A "closure" form of gs_mapping_proc. This allows the procedure to access 55 * client data for the purpose of filling in the transfer information. 56 * 57 * As with PostScript transfer functions, the operand will be in the range 58 * [0, 1], and the result should be in the same range. 59 */ 60 typedef gs_mapping_closure_proc_t gs_ht_transfer_proc; /* see gxtmap.h */ 61 62 /* 63 * Constructor, destructor, assign, and copy routines for a gs_ht 64 * structure, and to install them in the graphic state. 65 * 66 * Notes: 67 * 68 * Construction of a gs_ht halftone requires two steps: creating the 69 * overall halftone, and creating each of the components. Client data 70 * must be provided for each of the latter steps. 71 * 72 * The type field of gs_ht halftones will always be ht_type_multiple; 73 * if only one component is required, this halftone will always be given 74 * the component name "Default". 75 * 76 * The type fields of the gs_ht_component structures pointed to by the 77 * gs_multiple_ht structure will have the value ht_type_spot or 78 * ht_type_threshold; the constructor routines will not build any 79 * other types. 80 * 81 * Individual component halftones of a gs_ht structure must always be 82 * provided with transfer functions. 83 * 84 * Releasing the gs_ht structure will NOT release the client data 85 * (the client must do that directly). 86 */ 87 88 extern int gs_ht_build(gs_ht ** ppht, uint num_comps, gs_memory_t * pmem); 89 90 extern int gs_ht_set_spot_comp( 91 gs_ht * pht, 92 int component_index, 93 floatp freq, 94 floatp angle, 95 float (*spot_func) (floatp, floatp), 96 bool accurate, 97 gs_ht_transfer_proc transfer, 98 const void *client_data 99 ); 100 101 extern int gs_ht_set_threshold_comp( 102 gs_ht * pht, 103 int component_index, 104 int width, 105 int height, 106 const gs_const_string * thresholds, 107 gs_ht_transfer_proc transfer, 108 const void *client_data 109 ); 110 111 /* 112 * This procedure specifies a (possibly non-monotonic) halftone of size 113 * width x height with num_levels different levels (including white, always 114 * all 0s, but excluding black, always all 1s). Each mask is in the form of 115 * a gs_bitmap, except that there is no row padding -- the 'raster' is 116 * ceil(width / 8). 117 * 118 * Note that the client is responsible for releasing the mask data. 119 */ 120 extern int gs_ht_set_mask_comp( 121 gs_ht * pht, 122 int component_index, 123 int width, 124 int height, 125 int num_levels, 126 const byte * masks, /* width x height x num_levels */ 127 gs_ht_transfer_proc transfer, 128 const void *client_data 129 ); 130 131 extern void gs_ht_reference(gs_ht * pht); 132 extern void gs_ht_release(gs_ht * pht); 133 134 #define gs_ht_assign(pto, pfrom) \ 135 BEGIN \ 136 gs_ht_reference(pfrom); \ 137 if (pto != 0) \ 138 gs_ht_release(pto); \ 139 pto = pfrom; \ 140 END 141 142 #define gs_ht_init_ptr(pto, pfrom) \ 143 BEGIN gs_ht_reference(pfrom); pto = pfrom; END 144 145 extern int gs_ht_install(gs_state * pgs, gs_ht * pht); 146 147 #endif /* gshtx_INCLUDED */ 148