Standalone use

In the simplest form, the device can be created standalone, by passing passthrough as NULL.

As each subsequent device call is made, the device will test the graphic object passed to it to see if it is within the given threshold of being a neutral colour. If it is, then the device continues. If not, then it sets the int pointed to by is_color to be non zero.

For graphical objects such as paths or text, this is an easy evaluation that takes almost no time. For Images or Shadings however, it is slightly trickier. An image may be defined in a colour space capable of non-neutral colours (perhaps RGB or CMYK) and yet the image itself may only use neutral colours within that space. To properly establish whether colours are required or not, requires much more CPU intensive processing.

Accordingly, the device will, by default, just look at the colour space. The value of is_color returned at the end may be examined to establish the confidence level of the test. 0 means “definitely greyscale”, 1 means “probably colour” (i.e. “an image or shading was seen that potentially contains non neutral colours”), and 2 means “definitely colour”.

If the caller wishes to spend the CPU cycles to get a definite answer, options can be set to FZ_TEXT_OPT_IMAGES | FZ_TEXT_OPT_SHADINGS and images and shadings will be exhaustively checked.

As an optimisation, given how much faster is is to check non-images and shadings, it can be worth running the device once without the options set, and then only running it again with them set if required.

If the device is run with passthrough as NULL, then as soon as it encounters a “definite” non-neutral colour, it will throw a FZ_ABORT error. This can save a considerable amount of time, as it avoids the interpreter needing to run through an entire page when observation of one of the very first graphical operations is enough to know that colour is being used.