In order to represent a given color for a graphical object, we need both the color component values and details of the colorspace that the color is specified in. Color values are defined simply as floats (normally between 0 and 1 inclusive), and colorspaces are defined using the fz_colorspace structure.
As with many other such structures in MuPDF, these are reference counted objects (see section 21.3 Reference Counting).
MuPDF contains a set of inbuilt colorspaces that cover most simple requirements. These are the ‘device’ colorspaces:
MuPDF allows for indexed colorspaces - those where a palette is used to select color values from a (normally) larger colorspace.
These are created using the fz_new_indexed_colorspace call:
MuPDF Colorspaces are extensible, so specific document handlers can implement their own new spaces. A good example of this is how PDF implements Separation and DeviceN colorspaces.
These are special spaces which represent arbitrary sets of 1 or more colorants. These can either be mapped down to ‘equivalent’ colors in a more standard space, or (depending on the capabilities of the underlying device) processed in their raw form.
Further information on Colorspaces can be found within chapter 29 Colorspace Internals.