summaryrefslogtreecommitdiff
path: root/base/gen_ordered.h
blob: c625ba2e51cb9a75127ec9fafb589c8aebf324dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/* Copyright (C) 2001-2023 Artifex Software, Inc.
   All Rights Reserved.

   This software is provided AS-IS with no warranty, either express or
   implied.

   This software is distributed under license and may not be copied,
   modified or distributed except as expressly authorized under the terms
   of the license contained in the file LICENSE in this distribution.

   Refer to licensing information at http://www.artifex.com or contact
   Artifex Software, Inc.,  39 Mesa Street, Suite 108A, San Francisco,
   CA 94129, USA, for further information.
*/

/* Defines and exports for library (e.g., Ghostscript) use of gen_ordered.c */

#ifndef gen_ordered_INCLUDED
#  define gen_ordered_INCLUDED

#include "stdpre.h"

#ifndef RAW_SCREEN_DUMP
#  define RAW_SCREEN_DUMP 0	/* Noisy output for .raw files for detailed debugging */
#endif
#ifndef FINAL_SCREEN_DUMP
#  define FINAL_SCREEN_DUMP 0	/* Dump of the final PS result */
#endif
#if RAW_SCREEN_DUMP || FINAL_SCREEN_DUMP || !defined(LIB_BUILD)
#  define FULL_FILE_NAME_LENGTH 50
#endif

#define MAXVAL 65535.0
#define MIN(x,y) ((x)>(y)?(y):(x))
#define MAX(x,y) ((x)>(y)?(x):(y))
#define ROUND( a )  ( ( (a) < 0 ) ? (int) ( (a) - 0.5 ) : \
                                                  (int) ( (a) + 0.5 ) )
typedef enum {
    CIRCLE = 0,
    REDBOOK,
    INVERTED,
    RHOMBOID,
    LINE_X,
    LINE_Y,
    DIAMOND1,
    DIAMOND2,
    ROUNDSPOT,
    CUSTOM  /* Must remain last one */
} spottype_t;

typedef enum {
   OUTPUT_TOS = 0,
   OUTPUT_PS = 1,
   OUTPUT_PPM = 2,
   OUTPUT_RAW = 3,
   OUTPUT_RAW16 = 4
} output_format_type;

typedef struct htsc_param_s {
    double scr_ang;
    int targ_scr_ang;
    int targ_lpi;
    double vert_dpi;
    double horiz_dpi;
    bool targ_quant_spec;
    int targ_quant;
    int targ_size;
    bool targ_size_spec;
    spottype_t spot_type;
    bool holladay;
    double gamma;
    output_format_type output_format;
    int verbose;
} htsc_param_t;

typedef struct htsc_vector_s {
   double xy[2];
} htsc_vector_t;

typedef struct htsc_dig_grid_s {
    int width;
    int height;
    htsc_vector_t bin_center;
    void *memory;		/* needed if non-standard allocator */
    int *data;		/* may be int scaled to 65535 or pairs of turn-on-sequence */
} htsc_dig_grid_t;

/*
    For library usage, #define GS_LIB_BUILD needs to be specified when building
    gen_ordered.c. to leave out "main" and define ALLOC, FREE and PRINT/EPRINT
    macros as appropriate for Ghostscript use.

    Use as functions from other applications will need to #define the macros
    appropriately, adding an another ???_LIB_BUILD #define that also #defines
    LIB_BUILD
*/

/* Set reasonable defaults into the params */
void htsc_set_default_params(htsc_param_t *params);

/* Generate the threshold array given the params */
/*
    Note that final_mask.memory must be set as needed for the allocator and
    it is the callers responsibilty to free the final_mask.data that is returned.
*/
int htsc_gen_ordered(htsc_param_t params, int *S, htsc_dig_grid_t *final_mask, gs_memory_t *mem);

#if FINAL_SCREEN_DUMP
int htsc_save_screen(htsc_dig_grid_t *final_mask, bool use_holladay_grid, int S,
    htsc_param_t params, gs_memory_t *mem);
#endif

#endif