1Imager::Preprocess(3) User Contributed Perl DocumentationImager::Preprocess(3)
2
3
4

NAME

6       Imager::Preprocess - simple preprocessor for handling multiple sample
7       sizes
8

SYNOPSIS

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

DESCRIPTION

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       You can also define extra sample-size dependent macros with "#!define":
50
51           "#define" common-name eight-bit-name floating-point-name
52
53       The following types and values are defined in a #code section:
54
55       •   IM_GPIX("im", "x", "y", &col)
56
57       •   IM_GLIN("im", "l", "r", "y", "colors")
58
59       •   IM_PPIX("im", "x", "y", &col)
60
61       •   IM_PLIN("im", "x", "y", "colors")
62
63       •   IM_GSAMP("im", "l", "r", "y", "samples", "chans", "chan_count")
64
65           These correspond to the appropriate image function, eg. IM_GPIX()
66           becomes i_gpix() or i_gpixf() as appropriate.
67
68       •   IM_ADAPT_COLORS("dest_channels", "src_channels", "colors", "count")
69
70           Call i_adapt_colors() or i_adapt_fcolors().
71
72       •   IM_FILL_COMBINE("fill") - retrieve the combine function from a fill
73           object.
74
75       •   IM_FILL_FILLER("fill") - retrieve the fill_with_* function from a
76           fill object.
77
78       •   IM_ABS(sample) - calculate the absolute value of an IM_WORK_T
79           value.
80
81       •   IM_SAMPLE_MAX - maximum value for a sample
82
83       •   IM_SAMPLE_MAX2 - maximum value for a sample, squared
84
85       •   IM_SAMPLE_T - type of a sample (i_sample_t or i_fsample_t)
86
87       •   IM_COLOR - color type, either i_color or i_fcolor.
88
89       •   IM_WORK_T - working sample type, either int or double.
90
91       •   IM_Sf - format string for the sample type, "%d" or "%f".
92
93       •   IM_Wf - format string for the work type, "%d" or "%f".
94
95       •   IM_SUFFIX(identifier) - adds _8 or _double onto the end of
96           identifier.
97
98       •   IM_EIGHT_BIT - this is a macro defined only in 8-bit/sample code.
99
100       Other types, functions and values may be added in the future.
101

AUTHOR

103       Tony Cook <tonyc@cpan.org>
104
105
106
107perl v5.38.0                      2023-07-20             Imager::Preprocess(3)
Impressum