Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  IMAGER::PREPROCESS (3)

.ds Aq ’


Imager::Preprocess - simple preprocessor for handling multiple sample sizes



  /* in the source: */
  #code condition true to work with 8-bit samples
  ... code using preprocessor types/values ...

  # process and make #line directives
  perl -MImager::Preprocess -epreprocess foo.c

  # process and no #line directives
  perl -MImager::Preprocess -epreprocess -l foo.c


This is a simple preprocessor that aims to reduce duplication of source code when implementing an algorithm both for 8-bit samples and double samples in Imager.

Imager’s Makefile.PL currently scans the MANIFEST for .im files and adds Makefile files to convert these to .c files.

The beginning of a sample-independent section of code is preceded by:

  #code expression

where expression should return true if processing should be done at 8-bits/sample.

You can also use a #code block around a function definition to produce 8-bit and double sample versions of a function. In this case #code has no expression and you will need to use IM_SUFFIX() to produce different function names.

The end of a sample-independent section of code is terminated by:


#code sections cannot be nested.

#/code without a starting #code is an error.

The following types and values are defined in a #code section:
o IM_GPIX(im, x, y, &col)
o IM_GLIN(im, l, r, y, colors)
o IM_PPIX(im, x, y, &col)
o IM_PLIN(im, x, y, colors)
o IM_GSAMP(im, l, r, y, samples, chans, chan_count)

These correspond to the appropriate image function, eg. IM_GPIX() becomes i_gpix() or i_gpixf() as appropriate.

o IM_ADAPT_COLORS(dest_channels, src_channels, colors, count)

Call i_adapt_colors() or i_adapt_fcolors().

o IM_FILL_COMBINE(fill) - retrieve the combine function from a fill object.
o IM_FILL_FILLER(fill) - retrieve the fill_with_* function from a fill object.
o IM_SAMPLE_MAX - maximum value for a sample
o IM_SAMPLE_MAX2 - maximum value for a sample, squared
o IM_SAMPLE_T - type of a sample (i_sample_t or i_fsample_t)
o IM_COLOR - color type, either i_color or i_fcolor.
o IM_WORK_T - working sample type, either int or double.
o IM_Sf - format string for the sample type, "%d" or "%f".
o IM_Wf - format string for the work type, "%d" or "%f".
o IM_SUFFIX(identifier) - adds _8 or _double onto the end of identifier.
o IM_EIGHT_BIT - this is a macro defined only in 8-bit/sample code.
Other types, functions and values may be added in the future.


Tony Cook <>
Search for    or go to Top of page |  Section 3 |  Main Index

perl v5.20.3 IMAGER::PREPROCESS (3) 2014-04-12

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.