Any task that intends to use the ColourTrans module should ensure that a suitable version of the module is present on the system. This is achieved by *RMEnsure Command.
The following code is an excerpt from a typical Obey file used within an application to check the presence of a specific version of the ColourTrans module.
RMEnsure ColourTrans 1.78 RMLoad System:Modules.Colours RMEnsure ColourTrans 1.78 Error You need ColourTrans 1.78 or later
ColourTrans provides multiple SWIs that returns a colour based on a desired input colour. The return value can either be the closest match or the most unclose match.
In monochrome mode, the ECF patterns are not used to reflect shades of grey. This is in contrast to Wimp_SetColour that does.
ColourTrans provides a facility to convert GCOLs to colour numbers and vice versa. This only has meaning for 256 colour screen modes.
There are also SWIs that convert between different colour models such as RGB, CIE, HSV and CMYK.
The following SWIs are useful when dealing with sprite and fonts.
A detailed description on pixel translation tables can be found within the Sprites section.
ColourTrans maintains a cache containing the mapping of colours to the current palette. If a task changes the output palette, then it must inform ColourTrans by calling ColourTrans_InvalidateCache. This ensures that ColourTrans will update its own internal cache.
A task does not need to inform ColourTrans of a change in palette if a change in screen mode has occurred as it automatically updates its own cache. If however, a task changes a palette colour, or switching output to a sprite, then the task should inform ColourTrans.
A task that uses the Wimp interface can safely be used as they never modify the palette.
ColourTrans provides functionality to request a RGB colour rather than a logical colour and this makes it ideal for use with printer drivers, where a printer may be able to more accurately represent a colour using RGB.