1Imager::Preprocess(3) User Contributed Perl DocumentationImager::Preprocess(3)
2
3
4
6 Imager::Preprocess - simple preprocessor for handling multiple sample
7 sizes
8
10 /* in the source: */
11 #code condition true to work with 8-bit samples
12 ... code using preprocessor types/values ...
13 #/code
14
15 # process and make #line directives
16 perl -MImager::Preprocess -epreprocess foo.im foo.c
17
18 # process and no #line directives
19 perl -MImager::Preprocess -epreprocess -l foo.im foo.c
20
22 This is a simple preprocessor that aims to reduce duplication of source
23 code when implementing an algorithm both for 8-bit samples and double
24 samples in Imager.
25
26 Imager's "Makefile.PL" currently scans the MANIFEST for .im files and
27 adds Makefile files to convert these to .c files.
28
29 The beginning of a sample-independent section of code is preceded by:
30
31 #code expression
32
33 where expression should return true if processing should be done at
34 8-bits/sample.
35
36 You can also use a #code block around a function definition to produce
37 8-bit and double sample versions of a function. In this case #code has
38 no expression and you will need to use IM_SUFFIX() to produce different
39 function names.
40
41 The end of a sample-independent section of code is terminated by:
42
43 #/code
44
45 #code sections cannot be nested.
46
47 #/code without a starting #code is an error.
48
49 The following types and values are defined in a #code section:
50
51 · IM_GPIX("im", "x", "y", &col)
52
53 · IM_GLIN("im", "l", "r", "y", "colors")
54
55 · IM_PPIX("im", "x", "y", &col)
56
57 · IM_PLIN("im", "x", "y", "colors")
58
59 · IM_GSAMP("im", "l", "r", "y", "samples", "chans", "chan_count")
60
61 These correspond to the appropriate image function, eg. IM_GPIX()
62 becomes i_gpix() or i_gpixf() as appropriate.
63
64 · IM_ADAPT_COLORS("dest_channels", "src_channels", "colors", "count")
65
66 Call i_adapt_colors() or i_adapt_fcolors().
67
68 · IM_FILL_COMBINE("fill") - retrieve the combine function from a fill
69 object.
70
71 · IM_FILL_FILLER("fill") - retrieve the fill_with_* function from a
72 fill object.
73
74 · IM_SAMPLE_MAX - maximum value for a sample
75
76 · IM_SAMPLE_MAX2 - maximum value for a sample, squared
77
78 · IM_SAMPLE_T - type of a sample (i_sample_t or i_fsample_t)
79
80 · IM_COLOR - color type, either i_color or i_fcolor.
81
82 · IM_WORK_T - working sample type, either int or double.
83
84 · IM_Sf - format string for the sample type, "%d" or "%f".
85
86 · IM_Wf - format string for the work type, "%d" or "%f".
87
88 · IM_SUFFIX(identifier) - adds _8 or _double onto the end of
89 identifier.
90
91 · IM_EIGHT_BIT - this is a macro defined only in 8-bit/sample code.
92
93 Other types, functions and values may be added in the future.
94
96 Tony Cook <tonyc@cpan.org>
97
98
99
100perl v5.30.0 2019-07-26 Imager::Preprocess(3)