1 /****************************************************************************
2 * This source file was written by Acorn Computers Limited. It is part of *
3 * the RISCOS library for writing applications in C for RISC OS. It may be *
4 * used freely in the creation of programs for Archimedes. It should be *
5 * used with Acorn's C Compiler Release 3 or later. *
7 ***************************************************************************/
11 * Purpose: C interface to the ColourTrans SWIs
15 #ifndef __colourtran_h
16 #define __colourtran_h
31 /* ----------------------- colourtran_select_table -------------------------
32 * Description: Sets up a translation table in a buffer, given a source
33 * mode and palette, and a destination mode and palette.
35 * Parameters: int source_mode -- source mode
36 * wimp_paletteword *source_palette -- source palette
37 * int dest_mode -- destination mode
38 * wimp_paletteword *dest_palette -- destination palette
39 * void *buffer -- pointer to store for the table.
40 * Returns: possible error condition.
45 os_error *colourtran_select_table (int source_mode,
46 wimp_paletteword *source_palette,
48 wimp_paletteword *dest_palette,
52 /* ---------------------- colourtran_select_GCOLtable ----------------------
53 * Description: Sets up a list of GCOLs in a buffer, given a source
54 * mode and palette, and a destination mode and palette.
56 * Parameters: int source_mode -- source mode
57 * wimp_paletteword *source_palette -- source palette
58 * int dest_mode -- destination mode
59 * wimp_paletteword *dest_palette -- destination palette
60 * void *buffer -- pointer to store for the list of GCOLs.
61 * Returns: possible error condition.
66 os_error *colourtran_select_GCOLtable (int source_mode,
67 wimp_paletteword *source_palette,
69 wimp_paletteword *dest_palette,
73 /* ------------------------- colourtran_returnGCOL -------------------------
74 * Description: Informs caller of the closest GCOL in the current mode
75 * to a given palette entry.
77 * Parameters: wimp_paletteword entry -- the palette entry
78 * int *gcol -- returned GCOL value.
79 * Returns: possible error condition.
84 os_error *colourtran_returnGCOL (wimp_paletteword entry, int *gcol);
87 /* ------------------------ colourtran_setGCOL -----------------------------
88 * Description: Informs caller of the closest GCOL in the current mode
89 * to a given palette entry, and also sets the GCOL.
91 * Parameters: wimp_paletteword entry -- the palette entry
92 * int fore_back -- set to 0 for foreground,
93 * set to 128 for background
94 * int gcol_in -- GCOL action
95 * int *gcol_out -- returned closest GCOL.
96 * Returns: possible error condition.
101 os_error *colourtran_setGCOL (wimp_paletteword entry, int fore_back,
102 int gcol_in, int *gcol_out);
105 /* ---------------------- colourtran_return_colournumber -------------------
106 * Description: Informs caller of the closeset colour number to a given
107 * palette entry, in the current mode and palette
109 * Parameters: wimp_paletteword entry -- the palette entry
110 * int *col -- returned colour number.
111 * Returns: possible error condition.
116 os_error *colourtran_return_colournumber (wimp_paletteword entry, int *col);
119 /* --------------------- colourtran_return_GCOLformode ---------------------
120 * Description: Informs caller of the closest GCOL to a given palette
121 * entry, destination mode and destination palette.
123 * Parameters: wimp_paletteword entry -- the palette entry
124 * int dest_mode -- destination mode
125 * wimp_paletteword *dest_palette -- destination palette
126 * int *gcol -- returned closest GCOL.
127 * Returns: possible error condition.
132 os_error *colourtran_return_GCOLformode (wimp_paletteword entry,
134 wimp_paletteword *dest_palette,
138 /* ------------------ colourtran_return_colourformode ----------------------
139 * Description: Informs caller of the closest colour number to a given
140 * palette entry, destination mode and destination palette.
142 * Parameters: wimp_paletteword entry -- the palette entry
143 * int dest_mode -- destination mode
144 * wimp_paletteword *dest_palette -- destination palette
145 * int *col -- returned closest colour number.
146 * Returns: possible error condition.
151 os_error *colourtran_return_colourformode (wimp_paletteword entry,
153 wimp_paletteword *dest_palette,
157 /* ----------------------- colourtran_return_OppGCOL -----------------------
158 * Description: Informs caller of the furthest GCOL in the current mode
159 * from a given palette entry.
161 * Parameters: wimp_paletteword entry -- the palette entry
162 * int *gcol -- returned GCOL value.
163 * Returns: possible error condition.
168 os_error *colourtran_return_OppGCOL (wimp_paletteword entry, int *gcol);
171 /* ------------------------ colourtran_setOppGCOL --------------------------
172 * Description: Informs caller of the furthest GCOL in the current mode
173 * from a given palette entry, and also sets the GCOL.
175 * Parameters: wimp_paletteword entry -- the palette entry
176 * int fore_back -- set to 0 for foreground,
177 * set to 128 for background
178 * int gcol_in -- GCOL action
179 * int *gcol_out -- returned furthest GCOL.
180 * Returns: possible error condition.
185 os_error *colourtran_setOppGCOL (wimp_paletteword entry, int fore_back,
186 int gcol_in, int *gcol_out);
189 /* ---------------------- colourtran_return_Oppcolournumber ----------------
190 * Description: Informs caller of the furthest colour number from a given
191 * palette entry, in the current mode and palette
193 * Parameters: wimp_paletteword -- the palette entry
194 * int *col -- returned colour number.
195 * Returns: possible error condition.
200 os_error *colourtran_return_Oppcolournumber (wimp_paletteword entry,
204 /* --------------------- colourtran_return_OppGCOLformode ------------------
205 * Description: Informs caller of the furthest GCOL from a given palette
206 * entry, destination mode and destination palette.
208 * Parameters: wimp_paletteword entry -- the palette entry
209 * int dest_mode -- destination mode
210 * wimp_paletteword *dest_palette -- destination palette
211 * int *gcol -- returned furthest GCOL.
212 * Returns: possible error condition.
217 os_error *colourtran_return_OppGCOLformode (wimp_paletteword entry,
219 wimp_paletteword *dest_palette,
223 /* ------------------ colourtran_return_Oppcolourformode -------------------
224 * Description: Informs caller of the furthest colour number from a given
225 * palette entry, destination mode and destination palette.
227 * Parameters: wimp_paletteword entry -- the palette entry
228 * int dest_mode -- destination mode
229 * wimp_paletteword *dest_palette -- destination palette
230 * int *col -- returned furthest colour number.
231 * Returns: possible error condition.
236 os_error *colourtran_return_Oppcolourformode (wimp_paletteword entry,
238 wimp_paletteword *dest_palette,
242 /* ---------------------- colourtran_GCOL_tocolournumber -------------------
243 * Description: Translates a GCOL to a colournumber (assuming 256-colour
246 * Parameters: int gcol -- the GCOL
247 * int *col -- returned colour number.
248 * Returns: possible error condition.
253 os_error *colourtran_GCOL_tocolournumber (int gcol, int *col);
256 /* ----------------- colourtran_colournumbertoGCOL -------------------------
257 * Description: Translates a colour number to a GCOL (assuming 256-colour
260 * Parameters: int col -- the colour number
261 * int *gcol -- the returned GCOL.
262 * Returns: possible error condition.
267 os_error *colourtran_colournumbertoGCOL (int col, int *gcol);
270 /* ------------------ colourtran_returnfontcolours -------------------------
271 * Description: Informs caller of font colours to match given colours.
273 * Parameters: font *handle -- the font's handle
274 * wimp_paletteword *backgnd -- background palette entry
275 * wimp_paletteword *foregnd -- foreground palette entry
277 * Returns: possible error condition.
278 * Other Info: Closest approximations to fore/background colours will be
279 * set, and as many intermediate colours as possible (up to
280 * a maximum of *max_offset). Values are returned through
285 os_error *colourtran_returnfontcolours (font *handle,
286 wimp_paletteword *backgnd,
287 wimp_paletteword *foregnd,
291 /* -------------------- colourtran_setfontcolours --------------------------
292 * Description: Informs caller of font colours to match given colours, and
293 * calls font_setfontcolour() to set them.
295 * Parameters: font *handle -- the font's handle
296 * wimp_paletteword *backgnd -- background palette entry
297 * wimp_paletteword *foregnd -- foreground palette entry
299 * Returns: possible error condition.
300 * Other Info: Closest approximations to fore/background colours will be
301 * set, and as many intermediate colours as possible (up to
302 * a maximum of *max_offset). Values are returned through
303 * the parameters. Font_setfontcolours() is then called with
304 * these as parameters.
307 os_error *colourtran_setfontcolours (font *handle,
308 wimp_paletteword *backgnd,
309 wimp_paletteword *foregnd,
313 /* ----------------------- colourtran_invalidate_cache ---------------------
314 * Description: To be called when the palette has changed since a call was
315 * last made to a function in this module.
318 * Returns: possible error condition.
323 os_error *colourtran_invalidate_cache (void);
328 /* ----------------------- colourtran_convert_device_colour ----------------
329 * Description: Convert from a device colour to a standard RGB colour
331 * Parameters: wimp_paletteword device colour
332 wimp_paletteword *rgb colour
333 * Returns: possible error condition.
334 * Other Info: Uses the current calibration to convert from a device
335 * colour to a standard RGB palette entry
339 os_error *colourtran_convert_device_colour ( wimp_paletteword device,
340 wimp_paletteword *rgb );
343 /* end colourtran.h */