2ee739cc |
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. * |
6 | * * |
7 | ***************************************************************************/ |
8 | |
9 | /* |
10 | * Title: colourtran.h |
11 | * Purpose: C interface to the ColourTrans SWIs |
12 | * |
13 | */ |
14 | |
15 | #ifndef __colourtran_h |
16 | #define __colourtran_h |
17 | |
18 | #ifndef __os_h |
19 | #include "os.h" |
20 | #endif |
21 | |
22 | #ifndef __wimp_h |
23 | #include "wimp.h" |
24 | #endif |
25 | |
26 | #ifndef __font_h |
27 | #include "font.h" |
28 | #endif |
29 | |
30 | |
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. |
34 | * |
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. |
41 | * Other Info: none. |
42 | * |
43 | */ |
44 | |
45 | os_error *colourtran_select_table (int source_mode, |
46 | wimp_paletteword *source_palette, |
47 | int dest_mode, |
48 | wimp_paletteword *dest_palette, |
49 | void *buffer); |
50 | |
51 | |
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. |
55 | * |
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. |
62 | * Other Info: none. |
63 | * |
64 | */ |
65 | |
66 | os_error *colourtran_select_GCOLtable (int source_mode, |
67 | wimp_paletteword *source_palette, |
68 | int dest_mode, |
69 | wimp_paletteword *dest_palette, |
70 | void *buffer); |
71 | |
72 | |
73 | /* ------------------------- colourtran_returnGCOL ------------------------- |
74 | * Description: Informs caller of the closest GCOL in the current mode |
75 | * to a given palette entry. |
76 | * |
77 | * Parameters: wimp_paletteword entry -- the palette entry |
78 | * int *gcol -- returned GCOL value. |
79 | * Returns: possible error condition. |
80 | * Other Info: none. |
81 | * |
82 | */ |
83 | |
84 | os_error *colourtran_returnGCOL (wimp_paletteword entry, int *gcol); |
85 | |
86 | |
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. |
90 | * |
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. |
97 | * Other Info: none. |
98 | * |
99 | */ |
100 | |
101 | os_error *colourtran_setGCOL (wimp_paletteword entry, int fore_back, |
102 | int gcol_in, int *gcol_out); |
103 | |
104 | |
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 |
108 | * |
109 | * Parameters: wimp_paletteword entry -- the palette entry |
110 | * int *col -- returned colour number. |
111 | * Returns: possible error condition. |
112 | * Other Info: none. |
113 | * |
114 | */ |
115 | |
116 | os_error *colourtran_return_colournumber (wimp_paletteword entry, int *col); |
117 | |
118 | |
119 | /* --------------------- colourtran_return_GCOLformode --------------------- |
120 | * Description: Informs caller of the closest GCOL to a given palette |
121 | * entry, destination mode and destination palette. |
122 | * |
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. |
128 | * Other Info: none. |
129 | * |
130 | */ |
131 | |
132 | os_error *colourtran_return_GCOLformode (wimp_paletteword entry, |
133 | int dest_mode, |
134 | wimp_paletteword *dest_palette, |
135 | int *gcol); |
136 | |
137 | |
138 | /* ------------------ colourtran_return_colourformode ---------------------- |
139 | * Description: Informs caller of the closest colour number to a given |
140 | * palette entry, destination mode and destination palette. |
141 | * |
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. |
147 | * Other Info: none. |
148 | * |
149 | */ |
150 | |
151 | os_error *colourtran_return_colourformode (wimp_paletteword entry, |
152 | int dest_mode, |
153 | wimp_paletteword *dest_palette, |
154 | int *col); |
155 | |
156 | |
157 | /* ----------------------- colourtran_return_OppGCOL ----------------------- |
158 | * Description: Informs caller of the furthest GCOL in the current mode |
159 | * from a given palette entry. |
160 | * |
161 | * Parameters: wimp_paletteword entry -- the palette entry |
162 | * int *gcol -- returned GCOL value. |
163 | * Returns: possible error condition. |
164 | * Other Info: none. |
165 | * |
166 | */ |
167 | |
168 | os_error *colourtran_return_OppGCOL (wimp_paletteword entry, int *gcol); |
169 | |
170 | |
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. |
174 | * |
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. |
181 | * Other Info: none. |
182 | * |
183 | */ |
184 | |
185 | os_error *colourtran_setOppGCOL (wimp_paletteword entry, int fore_back, |
186 | int gcol_in, int *gcol_out); |
187 | |
188 | |
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 |
192 | * |
193 | * Parameters: wimp_paletteword -- the palette entry |
194 | * int *col -- returned colour number. |
195 | * Returns: possible error condition. |
196 | * Other Info: none. |
197 | * |
198 | */ |
199 | |
200 | os_error *colourtran_return_Oppcolournumber (wimp_paletteword entry, |
201 | int *col); |
202 | |
203 | |
204 | /* --------------------- colourtran_return_OppGCOLformode ------------------ |
205 | * Description: Informs caller of the furthest GCOL from a given palette |
206 | * entry, destination mode and destination palette. |
207 | * |
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. |
213 | * Other Info: none. |
214 | * |
215 | */ |
216 | |
217 | os_error *colourtran_return_OppGCOLformode (wimp_paletteword entry, |
218 | int dest_mode, |
219 | wimp_paletteword *dest_palette, |
220 | int *gcol); |
221 | |
222 | |
223 | /* ------------------ colourtran_return_Oppcolourformode ------------------- |
224 | * Description: Informs caller of the furthest colour number from a given |
225 | * palette entry, destination mode and destination palette. |
226 | * |
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. |
232 | * Other Info: none. |
233 | * |
234 | */ |
235 | |
236 | os_error *colourtran_return_Oppcolourformode (wimp_paletteword entry, |
237 | int dest_mode, |
238 | wimp_paletteword *dest_palette, |
239 | int *col); |
240 | |
241 | |
242 | /* ---------------------- colourtran_GCOL_tocolournumber ------------------- |
243 | * Description: Translates a GCOL to a colournumber (assuming 256-colour |
244 | * mode). |
245 | * |
246 | * Parameters: int gcol -- the GCOL |
247 | * int *col -- returned colour number. |
248 | * Returns: possible error condition. |
249 | * Other Info: none. |
250 | * |
251 | */ |
252 | |
253 | os_error *colourtran_GCOL_tocolournumber (int gcol, int *col); |
254 | |
255 | |
256 | /* ----------------- colourtran_colournumbertoGCOL ------------------------- |
257 | * Description: Translates a colour number to a GCOL (assuming 256-colour |
258 | * mode). |
259 | * |
260 | * Parameters: int col -- the colour number |
261 | * int *gcol -- the returned GCOL. |
262 | * Returns: possible error condition. |
263 | * Other Info: none. |
264 | * |
265 | */ |
266 | |
267 | os_error *colourtran_colournumbertoGCOL (int col, int *gcol); |
268 | |
269 | |
270 | /* ------------------ colourtran_returnfontcolours ------------------------- |
271 | * Description: Informs caller of font colours to match given colours. |
272 | * |
273 | * Parameters: font *handle -- the font's handle |
274 | * wimp_paletteword *backgnd -- background palette entry |
275 | * wimp_paletteword *foregnd -- foreground palette entry |
276 | * int *max_offset |
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 |
281 | * the parameters. |
282 | * |
283 | */ |
284 | |
285 | os_error *colourtran_returnfontcolours (font *handle, |
286 | wimp_paletteword *backgnd, |
287 | wimp_paletteword *foregnd, |
288 | int *max_offset); |
289 | |
290 | |
291 | /* -------------------- colourtran_setfontcolours -------------------------- |
292 | * Description: Informs caller of font colours to match given colours, and |
293 | * calls font_setfontcolour() to set them. |
294 | * |
295 | * Parameters: font *handle -- the font's handle |
296 | * wimp_paletteword *backgnd -- background palette entry |
297 | * wimp_paletteword *foregnd -- foreground palette entry |
298 | * int *max_offset |
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. |
305 | * |
306 | */ |
307 | os_error *colourtran_setfontcolours (font *handle, |
308 | wimp_paletteword *backgnd, |
309 | wimp_paletteword *foregnd, |
310 | int *max_offset); |
311 | |
312 | |
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. |
316 | * |
317 | * Parameters: void. |
318 | * Returns: possible error condition. |
319 | * Other Info: none. |
320 | * |
321 | */ |
322 | |
323 | os_error *colourtran_invalidate_cache (void); |
324 | |
325 | |
326 | /* new SWIs */ |
327 | |
328 | /* ----------------------- colourtran_convert_device_colour ---------------- |
329 | * Description: Convert from a device colour to a standard RGB colour |
330 | * |
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 |
336 | * |
337 | */ |
338 | |
339 | os_error *colourtran_convert_device_colour ( wimp_paletteword device, |
340 | wimp_paletteword *rgb ); |
341 | |
342 | #endif |
343 | /* end colourtran.h */ |